I'm using avr libc 1.4.6 and gcc 4.1.2 with patches from winavr.
I have written the following (simplified) code:
... char sd; uint8_t test; ... test = 13; ... sprintf(sd, "%d", test); ... sprintf(sd, "%d", test);
The first sprintf was working ok, but the second was not.
I've debuged it with JTAG and I've found this:
- After steped into the 1st sprintf, the "fmt" (format string was "%d" as expected. So far so good.
- After steped into the 2nd sprintf, the "fmt" was 0x04 0x02 0x00 !!! :S Then "sd" resulted in 0x04 0x02 0x00 confirming the bad "fmt"
I've checked RAM and there was no stack overflow.
What could be causing the problem?
Maybe the code between is misbehaving?
I've searched for similar problems and I've come across this old post with no answer: