- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Using Psoc4 CY8C4235AXI-483
Environment:
PSoC Creator 4.4 (4.4.0.80)
Culture: English (United States)
OS Version: Microsoft Windows NT 10.0.19043.0
CLR Version: 4.0.30319.42000
I need to print out 64bit Unix Clock values in order to debug.
The %llu format does not work correctly according to my understanding.
I tried I64 but the compiler will not accept it.
I tried to convert to uint32 but I lose too much of the number
Code : (void)snprintf(printBuff, 100u,"RTC value: %llu \r\n", CURRENT_TIME);
UART_PutString(printBuff);
Expected output: RTC value: 1647092905000
Actual output : RTC value: lu
Is the compiler screwed up? Am I screwed up?
Solved! Go to Solution.
- Labels:
-
PSoC 4 MCU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
DoLo,
I have reproduced the issue you are seeing.
I have a solution.
Go to menu "Project/Build Settings .../ARM GCC xxxx/Linker/General"
Change "Use newlib-nano" to FALSE. The select "OK". Recompile.
The issue is that the newlib.nano library is a smaller code version of the standard library. Whoever supplied this library decided that 64-bit operations are very rarely used. The standard library correctly handles '%llu".
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
DoLo,
I have reproduced the issue you are seeing.
I have a solution.
Go to menu "Project/Build Settings .../ARM GCC xxxx/Linker/General"
Change "Use newlib-nano" to FALSE. The select "OK". Recompile.
The issue is that the newlib.nano library is a smaller code version of the standard library. Whoever supplied this library decided that 64-bit operations are very rarely used. The standard library correctly handles '%llu".
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Len,
I found this solution earlier but as you suggested; "the newlib.nano library is a smaller code version of the standard library". And as you also stated; "Engineering is an Art. The Art of Compromise."
I tried it and I already don't have enough room for the larger library. I have a work around and if I want the whole number I can break it up into 2 32 bit words and print them out separately.
As you also stated; "Engineering is an Art. The Art of Compromise." I appreciate the smaller library.
Therefore I will accept this "Compromise". Thank -you
Doug
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
DoLo,
Breaking up a 64-bit into two 32-bit numbers is easy if your sprintf() output is in HEX. If it's in decimal, it's a bit more complex as you already found.
For we engineers: Economic "Compromise" is the most frequent type we need to balance.
"Engineering is an Art. The Art of Compromise."