Thanks Chris.

The weird thing is I have like 8kb of RAM, but the firmware crashes on
printf statements. msp430-size tells me that data+bss is 2666, so I believe
I have enough RAM.

We're using Z1 nodes, and the JTAG connector is somewhat complex to access
(they charge 16 bucks for every connector, Im looking to make one myself
right now) so access to the PC to see where it stopped is limited as of
now. The app works properly and never crashes if we dont use printf, so I
dont know what could be happening..

Although, I am using TimerA to generate 1 ms interrupts using the external
32768 crystal to keep an internal clock... is printf friendly with such
kind (rapid) of interrupts?

Another related question. What really happens when the memory gets
overwritten? Why does the msp430 crashes instead of going back to the start
of the program? Does the PC get stuck? Does it generate an interruption?

Thanks!

On Mon, Nov 14, 2011 at 7:53 PM, Chris Liechti <cliec...@gmx.net> wrote:

> Am 14.11.2011 19:15, schrieb Sergio Campamá:
> > Hello,
> >
> > I'm developing an app that uses heavily printf for debugging... Now, when
> > activated (through a DEBUG macro), the app crashes very rapidly, being
> > random the moment it crashes (almost always it crashes mid sentence)...
>
> crashes often happen when memory gets overwritten...
> either some buffer overflow or more common, stack overflow.
> a stack overflow is when the stack gets too large and starts overwriting
> the heap (if you're using it - i would not) or variables.
>
> calls to printf put the arguments on the stack and itself uses a couple
> of bytes on the stack. you should leave enough free RAM.
>
> also note that the older printf in mspgcc 3.2.3 has a limitation of max.
> 20 characters when using "%s". the latest version in the 4.x series does
> not have any limitation.
>
> > I just found this page:
> > http://processors.wiki.ti.com/index.php/Tips_for_using_printf
> >
> > How much of it correlates to the way mspgcc handles printf? Is it the
> same?
> > Can I use the same techniques for using static memory for printf?
> >
> > Basically, i want to use this (I'm trying to extract the most important
> > info of the page)
> >
> > char static_array[20];
> > setvbuf(stdout, static_array, _IOLBF, sizeof(static_array));
> >
> > Does this work on mspgcc?
>
> no. mspgcc's printf just calls a function named "putchar" you can
> implement that function to do what you want.
>
> (there is also uprintf which accepts a function pointer so that you can
> use your own functions instead of putchar).
>
> chris
>
>
> ------------------------------------------------------------------------------
> RSA(R) Conference 2012
> Save $700 by Nov 18
> Register now
> http://p.sf.net/sfu/rsa-sfdev2dev1
> _______________________________________________
> Mspgcc-users mailing list
> Mspgcc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users
>



-- 
--------------------------------------
Sergio Campamá
sergiocamp...@gmail.com
------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to