PutChar

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
OsFe_2822791
Level 3
Level 3
25 replies posted 10 replies posted 10 questions asked

Hello,

I am using PSoC 5LP and I want to send data to Matlab. I use for example UART_1_PutChar('705'); and I receive only the 5 value. I check the output using Putty and I only see the 5. However, I see some projects that use PutChar to send several, for example: https://www.youtube.com/watch?v=tRZ0t7pupLs

 

Thank you in advance.

 

Best Regards.

0 Likes
1 Solution
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

To print an integer value, you could write something like

===============

#define STR_BUF_LEN 64

char str[STR_BUF_LEN+1] ;

int32_t raw_value ;

...

raw_value = ADC_DelSig_1_GetResult32() ;

snprintf(str, STR_BUF_LEN, "%d", raw_value) ; // format could be "value = %d\n\r"

UART_1_PutString(str) ;

...

===============

moto

 

View solution in original post

0 Likes
4 Replies
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

OsFe,

Te PutChar(ch) accepts only ASCII characters from 0 to 255. So is trimmed to 5. If you need to send ASCII string "705" you need to use PutString("705") command. If you need to send a value, you need to convert 705 into 2-byte array and use PutArray()

Hello,

thank you for your response. So, it would be possible to use PutChar to send the value of the ADC obtained from ADC_DelSig_1_GetResult32(); ?

Regards.

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

To print an integer value, you could write something like

===============

#define STR_BUF_LEN 64

char str[STR_BUF_LEN+1] ;

int32_t raw_value ;

...

raw_value = ADC_DelSig_1_GetResult32() ;

snprintf(str, STR_BUF_LEN, "%d", raw_value) ; // format could be "value = %d\n\r"

UART_1_PutString(str) ;

...

===============

moto

 

0 Likes

Hello Moto,

thank you for you response, that helps me.

Regards.