Using UART transmites INT type datum ,the datum must be ASCII type ,how to transform into datum of INT type when recieving?
You can use itoa function to convert an integer variable into ascii and transmit over UART. Check out the below article.
If you want to convert an ascii string to integer, then you could use the atoi function.
thanks a lot! but how can I transform the ascii codes into a integer when recieving the ascii codes by UART?Best Regards,CAI
I'm sorry if this is obvious, but i cant seem to get the code working.
When I use the following code sample in the article:
char *itoa(char *string, int value, int base);
char AsciiString; //Buffer to Store the ASCII
UART_1_PutString(itoa(AsciiString, Sample_Value, 10));
(Where Sample_Value is the int im trying to convert and transfer over UART - it is an ADC code)
I get the following error:
prj.M0120: implicit declaration of function 'itoa'
prj.M0120: incompatible implicit declaration of function 'itoa'
prj.M0121: Passing argument 1 of 'UART_1_PutString' makes pointer from integer without a cast
Thank you in advance,
Sounds like you forgot to include the StdLib library -
that should fix it...