psoc3 newbee: how do I convert data, any form, into strings so that I can output to the onboard UART?

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

cross mob
RoBu_286116
Level 1
Level 1

Being very experienced hardware guy, I have UART sending info to host computer. However I can only send ascii characters (just to verify it all works).  But I can't figure out what to do in code. Tried using sprintf to convert, etc, but so far nothing works. So, pretend I have a value, a=57, for example. How do I process that and use UART calls to send it out ?

   

Thank you. Bob

0 Likes
4 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Welcome in the forum, Bob.

   

The magic word is: sprintf(), or rather the magic function. Look here publications.gbdirect.co.uk/c_book/chapter9/formatted_io.html

   

You simply convert a value (int, char, float...) into a string (see that it is big enough!) and send it via UART.

   

 

   

Bob

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

... and here an actual discussion about having problems with sprintf()

   

www.cypress.com/ 

   

 

   

Bob

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

One comment. It seems that the default heap size (128 bytes) used by Creator 3.1 is too small for all the printf-related stuff. So open the *.cydwr file and set it to something like 1024 bytes.

0 Likes