Hi, i'm setting the mutex at only one point with this code:
if (com_transmit.len) SET_RS232_MUTEX; with these defines: # define RS232_MUTEX (c_mutex & 0x01) // Mutex for RS232 # define NOT_RS232_MUTEX (! RS232_MUTEX) // invers # define SET_RS232_MUTEX (c_mutex |= 0x01) // Set # define CLEAR_RS232_MUTEX (c_mutex &= ~0x01) // clear with the volatile char c_mutex. At the point where the rs232 data has to be transmitted the check of transmit.len (uint16_t) is done with this code: if (0== com_transmit.len) // transmit length zero; should never happen { kernel_panic (); // endless LED blinking with interrupts disabled } By the LED blinking i can see that the impossible sometimes happens. Because the mutex is used in ISRs i started with volatile char c_mutex=0; volatile struct transmit com_transmit; but sometimes the mutex was set although the only point where this could happen was never reached and all data already have been transmitted. By changing the definition for c_mutex to volatile static unsigned char c_mutex = 0; the bug vanished. I have changed nothing else and before i checked the source code and could find no reason of this bug. Changing all global volatile variables to (module global) volatile static variables also removed the bug that writing to an I2C EEPROM works fine but reading only works in the first minute after an POR. After adding static the kernel_panic never happened again, although i tested with millions of data packages (and mutex uses). Regards, Rolf mspgcc-users@lists.sourceforge.net schrieb am 02.08.05 08:24:42: > > What exactly does not seem to work? > ~d > > -----Original Message----- > From: mspgcc-users-ad...@lists.sourceforge.net > [mailto:mspgcc-users-ad...@lists.sourceforge.net] On Behalf Of > nobo...@web.de > Sent: Saturday, July 30, 2005 2:29 AM > To: mspgcc-users@lists.sourceforge.net > Subject: [Mspgcc-users] strange error > > > Hi, > > for locking/unlocking resources i'm using volatile variables as mutexes > but that does work only sometimes with mspgcc. > After changing the declaration > > volatile unsigned char > > to > > volatile static unsigned char > > now it works although in aout.lst only the line > > 00000200 g O .data 00000001 c_mutex > > is changed to > > 00000200 l O .data 00000001 c_mutex > . > > What can be the reason of the error? > > Regards, > > Rolf > > > > > > ------------------------------------------------------- > SF.Net email is sponsored by: Discover Easy Linux Migration Strategies > from IBM. Find simple to follow Roadmaps, straightforward articles, > informative Webcasts and more! Get everything you need to get up to > speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click > _______________________________________________ > Mspgcc-users mailing list > Mspgcc-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mspgcc-users > > > > ------------------------------------------------------- > SF.Net email is sponsored by: Discover Easy Linux Migration Strategies > from IBM. Find simple to follow Roadmaps, straightforward articles, > informative Webcasts and more! Get everything you need to get up to > speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click > _______________________________________________ > Mspgcc-users mailing list > Mspgcc-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mspgcc-users