cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1 MCU

Anonymous
Not applicable
        Using UART transmites INT type datum ,the datum must be ASCII type ,how to transform into datum of INT type when recieving?   
0 Likes
4 Replies
MR_41
Employee
        You can use itoa function to convert an integer variable into ascii and transmit over UART. Check out the below article.   
   
    http://www.planetpsoc.com/comp...integer-to-ascii.html    
   
If you want to convert an ascii string to integer, then you could use the atoi function.   
0 Likes
Anonymous
Not applicable
        thanks a lot! but how can I transform the ascii codes into a integer when recieving the ascii codes by UART?   
Best Regards,   
CAI   
0 Likes
Anonymous
Not applicable

Hi Ganesh,

   

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[7]; //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

   

 

   

Please help!

   

Thank you in advance,

   

Anish

0 Likes
Anonymous
Not applicable

Hi Anish,

   

Sounds like you forgot to include the StdLib library -

   

#include “stdlib.h”
 

   

that should fix it...

   

 

   

regards,

   

Tom Moxon

   

www.moxon.com

   

www.westmarkco.com

0 Likes