Hi Todd,

Yes generally the msp430-libc is not thread safe. There are a few other 
examples that will do strange things, like strtok()

If your calling printf from inside a ISR at the same time as calling the same 
function from another task (main routine) what do you expect to be output? 
should one message be output in the middle of the other.

Regards,

Pete



----- Original Message ----
> From: Todd Allen <[email protected]>
> To: GCC for MSP430 - http://mspgcc.sf.net <[email protected]>
> Sent: Sunday, 21 June, 2009 12:11:02 AM
> Subject: [Mspgcc-users] snprintf and interrupts
> 
> I finally tracked down an intermittent bug I was having -- strings
> constructed via snprintf() were being corrupted.  The problem turned out to
> be that I was also calling snprintf() within an interrupt service routine
> that was executed once per second.  snprintf() calls vsnprintf(), which
> stashes a pointer and a length in external variables.  So of course when an
> interrupt which calls snprintf() happens to land in the middle of a call to
> snprintf(), the string gets corrupted.
> 
> Is it, in general, a bad idea to call library routines from ISRs, or is this
> an isolated case?
> 
> Thanks,
> Todd



      Access Yahoo!7 Mail on your mobile. Anytime. Anywhere.
Show me how: http://au.mobile.yahoo.com/mail

Reply via email to