DSPRelated.com
Forums

Problem with printf

Started by rowkajjh November 1, 2007
Hello,

I'm using CCSTudio 3.3 and have a problem with printf. After several
printf's in my code the memory gets corrupt. This means some static
variables have random contents or mathematical functions like sin or
atan2 are giving wrong results.

After changing the printf's to puts everything is fine. But I would
like to know whats the cause.

Thanks and bye!
Heya,

I just encountered the same problem with the printf function.

I figured out that a too small heap allocation caused overflows
in the memory. So I suggest you to increase the heap size for
your application.You can change the heap size in the Build options
and then the Linker tab. Or if you are using a DSP/Bios project,
by right clicking on one of your memory definitions > properties >
create heap in this memory.

My stack size was also too small so that the program
reported an "PC: wrong instruction 0xbla" error message after
running for some time.

Viel Erfolg
dorian
I don't think it is a heap memory problem.
Most likely it is a small vs. large memory model.
The printf provided by TI and their BIOS is compiled using the small memory model.
Therefore, if the input string to your printf falls outside the small memory range (eg, in a far away heap) then the printf will print some string from a totally wrong place.This is an issue that TI should address.

To: c...CC: r...@yahoo.deFrom: d...@redcodes.netDate: Thu, 1 Nov 2007 23:23:39 +0800Subject: [code-comp] Re:Problem with printf

Heya,I just encountered the same problem with the printf function.I figured out that a too small heap allocation caused overflowsin the memory. So I suggest you to increase the heap size foryour application.You can change the heap size in the Build options and then the Linker tab. Or if you are using a DSP/Bios project, by right clicking on one of your memory definitions > properties >create heap in this memory.My stack size was also too small so that the program reported an "PC: wrong instruction 0xbla" error message after running for some time. Viel Erfolgdorian