Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/25/02 15:34
Read: times


 
#26307 - RE: external IRQ and I2C with KEIL C,80537
Hi Markus,

The compiler is flagging this as an error because you have the possibility of a function being executed, an interrupt occurring and the same function being executed again... What happens to that function's (first call) local variables? They get stepped on and corrupted in the ISR function call (second call).

You might be able to bypass this problem by declaring the function reentrant so the compiler will use a separate memory space for locals for each calling of the function. Simpler perhaps would be to take Thomas' advice and make a second function, a copy of the first, for use only by the ISR.

But then again if you're dealing with I/O that poses more problems...for example, if the function was reading from a device, and the ISR also wants to read from the device, which function receives what data? It might run *most* of the time except for that rare instance where the timing was just right and you get the wrong results. A very difficult interrmittent problem to find! This is an example of why careful design before coding needs to be done.

In your case, you probably really don't have a problem *IF* your call to kb_init is done before interrupts are enabled. If that's the case you can possibly disable that particular error check.

Good luck!

Dennis



List of 5 messages in thread
TopicAuthorDate
external IRQ and I2C with KEIL C,80537            01/01/70 00:00      
RE: external IRQ and I2C with KEIL C,80537            01/01/70 00:00      
RE: external IRQ and I2C with KEIL C,80537            01/01/70 00:00      
RE: external IRQ and I2C with KEIL C,80537            01/01/70 00:00      
RE: external IRQ and I2C with KEIL C,80537            01/01/70 00:00      

Back to Subject List