UART Communication with PC Through FTDI

Using VSDSP legacy command line tools.
avizet
Senior User
Posts: 28
Joined: Tue 2021-06-29 11:25

Re: UART Communication with PC Through FTDI

Post by avizet »

HI!

Can you please share , How to take string input ? maybe normal c structure doesn't work here.

Waiting for your response.

Code: Select all

char token[100];
gets(token);
scanf("%s",token);
Thank you.
Hannu
VLSI Staff
Posts: 559
Joined: Mon 2016-05-30 11:54
Location: Finland
Contact:

Re: UART Communication with PC Through FTDI

Post by Hannu »

You have to write your own tokenizer. scanf() functions aren't available. Other normal C string functions are however available.

fgets(token, sizeof(token), stdin);

strchr() from string.h can easily used to find delimeter. And ctype.h has all the isspace() and friends.
strtol() is available for converting string to numbers.
avizet
Senior User
Posts: 28
Joined: Tue 2021-06-29 11:25

Re: UART Communication with PC Through FTDI

Post by avizet »

Hi Hannu!

Thanks for the replay. I had used this syntax fgets(token, sizeof(token), stdin); for string input but here is a limitation. If I declarer the length of token =10
char token[10];
then I need to give 10 char input for going to next step.
If I give 1-9 input and press enter to proceed for next step, it doesn't work.
Can you please help me to overcome this limitation?

Thank you!
Hannu
VLSI Staff
Posts: 559
Joined: Mon 2016-05-30 11:54
Location: Finland
Contact:

Re: UART Communication with PC Through FTDI

Post by Hannu »

fgets() man page wrote: fgets() reads in at most one less than size characters from stream and stores them into the buffer pointed to by s. Reading stops after an EOF or a newline. If a newline is read, it is stored into the buffer. A terminating null byte ('\0') is stored after the last character in the buffer.
char *nl= strchr(token, '\n');
if (nl)*nl = '\0';
else printf("Longer line than expected\n");
avizet
Senior User
Posts: 28
Joined: Tue 2021-06-29 11:25

Re: UART Communication with PC Through FTDI

Post by avizet »

Hi!

I need a favor from you. Can you please let me know the exact address of RX and TX pin of VS1010D mini demo board? From the datasheet of VS1010 I'm bit confused about the RX, TX pin correct address.

How to manually toggle the RX and TX pin by configuring the RX and TX pin as GPIO pin?

Thank you.
avizet
Senior User
Posts: 28
Joined: Tue 2021-06-29 11:25

Re: UART Communication with PC Through FTDI

Post by avizet »

Hi!

How to configure the RX and TX pin as GPIO pin and toggle the RX and TX pin in Mini DEMO board vs1010D? Example will be preferred.

Thank You!
Hannu
VLSI Staff
Posts: 559
Joined: Mon 2016-05-30 11:54
Location: Finland
Contact:

Re: UART Communication with PC Through FTDI

Post by Hannu »

RX0 is GPIO1_8, TX0 GPIO1_9, TX1 GPIO1_10, RX1 GPIO1_11

From vo_gpio.h there are the functions. When you want to get back to UART console, remember to call GpioSetAsPeripheral() function or else you don't have console.
gpio functions have pins as (gpio port << 4) |( port pin & 0xf) which gives uart pins: 0x18, 0x19, 0x1a, 0x1b values to be used with those functions.
avizet
Senior User
Posts: 28
Joined: Tue 2021-06-29 11:25

Re: UART Communication with PC Through FTDI

Post by avizet »

Thank you for the replay. I'll try that out.

Thank You!
Post Reply