Vahbiz Pestonjamasp

Problems when accessing Global variables in ISR and Source code

Discussion created by Vahbiz Pestonjamasp on Mar 5, 2007
Latest reply on Apr 2, 2007 by Vahbiz Pestonjamasp

Hello Sir

I am using CodeWarrior V5.6 to program freescale's Power Quicc processor MPC852T. I am having a problem with Global variables which are being used in both source code and ISR. I have a code in which a global variable "Count" gets incremented in the ISR and is being decremented in a function in the source code. Now it so happens that an interrupt comes while this function (in the source code) is executing. Most of the times this code works fine, ie at the end of the function this "count" value shows the increment. But sometime, at random this does not happen, althought the ISR has got executed ie  this "count" value shows NO increment and is not updated. What can be the cause of this problem? How can i avoid it? Are there any special compiller options that i need to set?

Also i have not enabled any optimisation setting in Codewarrior IDEand i also tried making this global variable "volatile" but there was no effect

Thanks,

Vahbiz

Outcomes