Hey guys,
I am working on a program and I noticed a strange behavior I cannot understand yet.
You see I have 2 global variables. I set a value to each of those variables in main()
I also have an interrupt that uses those variables. Everything was working great until I added those variables. I also tested it out in the MPLABX simulator, again giving strange behavior.
Then I took the 2 lines of code from the main (shown above) and put it in the interrupt. And it worked like a charm. I don't access those variables ANYwhere else. Just within the interrupt.
Could you please enlighten me?
Thanks
I am working on a program and I noticed a strange behavior I cannot understand yet.
You see I have 2 global variables. I set a value to each of those variables in main()
Code:
unsigned short var1=0;
unsigned short var2=0;
...
void main(void)
{
var1=1;
var2=2;
}
I also have an interrupt that uses those variables. Everything was working great until I added those variables. I also tested it out in the MPLABX simulator, again giving strange behavior.
Then I took the 2 lines of code from the main (shown above) and put it in the interrupt. And it worked like a charm. I don't access those variables ANYwhere else. Just within the interrupt.
Could you please enlighten me?
Thanks