Is it possible to share more info in this forum. This can happen if the output string length of sprintf exceed the destination string length. Can you check this.
We were about 20 characters into a 1024 byte buffer. Clearly the buffer is amply sized because doing it in two function calls works.
1 of 1 people found this helpful
More or less a guess: Increase the heap size to 0x0200 bytes.
When nothing helps, consider to post your complete project, so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.
I can tell you from personal experience heap size is the problem. Increase as needed until sprintf behaves.
Other than that bundle appearing to contain all our IP and not just the project settings that sounds like a great idea.
I will attempt the heap size fix when I next touch this.
It is probably the case that heap size is the problem as others have said. You can increase this in the System tab of the cydwr window. Having said that, I'm not sure what you mean by the variable containing garbage. If you are printing the variables out in a terminal window, be sure your UART parameters agree with your term parameters. Also be sure your code starts the UART and its interrupt: UART_1_Start(); and isr_1_Start(); for example. I once forgot to put in these lines and I got garbage on the screen.
By garbage I mean something other than the contents of my string. if myUID is 8 and sSequence is "ABCD" the first block will give a string of:
But the second block will give:
"8,ACK,<a few unprintable characters, variable each time it's run>"
Assuming you are using UART and a terminal program to read the output, be sure to connect P0 to TX, both by physical wire on the development board (assuming you are using one) and in your cydwr.
If you were using the GNU compiler I would say to check build settings and go to Linker > General and make newlib-nano and newlib-nano Float Format both True. From your other posts, I think you might be using the Keil compiler. I'm not sure what the equivalent settings there are.