- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've searched and read other threads in this forum but I can't get this to be recognized. I want to take an ADC result and convert it to a string so I can send t out over UART.
itoa seems not to be recognized.
I'm in PSoC creator 4.1 and the compiler is GCC 4.1.0.2686
Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did you #include <stdlib.h>
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Bob, now I have #include
Where can I find the documentation of all the extra functions that are in stdlib.h?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Best place will be GCC documentation. Additional libraries of interest is newlib-nano.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, one other question if I may... now I have the result coming from the ADC and I use itoa() to convert it, like this...
itoa(ADC_SAR_Seq_1_GetResult16(1),buffy, 10);
The char string built in buffy (an array of char) is clearly assuming that the integer input is signed so a 0xFFF result reads -2048, is there a simple way to cast this so that I don't have that issue?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
itoa() macro is a kind of simple. Did you ever consider using formatted IO with printf().
This will require some settings:
In Project -> Build Settings -> Linker set "Use Newlib nano" and "use newlib nano float formatting" (if you need that)
In System view set Heap Size to 0x0200
In your modules #include <stdio.h>
For formatted I/O see here. Best will be sprintf(Buffer,...) and UART_PutString(Buffer)
Do not forget to put a delimiter at end of your string. So the receiver will be able to detect and syncronize to the begin of a new sequence.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Bob, thanks for those suggestion which I'll investigate. I read up on newlib-nano and it seems to be applying some neat algorithms to make sprintf() and printf() statements as small as possible in the compiled code. Can you comment on that? Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, newlib nano has a very small footprint. Only exception to standard is that the scanf() functions are not contained.
Bob