Pete, It was not printf, but various combinations of snprintf and vsnprintf that caused the trouble. Everything leads to vuprintf, which, along with vsnprintf, has static external variables, making it not thread safe.
I'm in the process of rewriting the ISR so that it does not need msp430-libc, like it should have been in the first place... Thanks for the reply, Todd On Sun, Jun 21, 2009 at 7:05 PM, Peter Jansen <[email protected]> wrote: > > 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 > > > ------------------------------------------------------------------------------ > Are you an open source citizen? Join us for the Open Source Bridge > conference! > Portland, OR, June 17-19. Two days of sessions, one day of unconference: > $250. > Need another reason to go? 24-hour hacker lounge. Register today! > > http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org > _______________________________________________ > Mspgcc-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/mspgcc-users >
