psquare
Newbie level 6
- Joined
- May 13, 2012
- Messages
- 14
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,429
Hello to all
I have encountered some very serious problem in MG84FG516 controller using the Keil C51 compiler.
In my code I am using three interrupts in the priority as follows:
1 - Serial port 0
2 - Timer 0 to generate 300 us interrupt.
3 - Timer 1 to generate 5 ms interrupt.
Actually there are few functions like keypad scanning , battery power checkup, and other hardware related functionalities which are carried out in the 5 ms timer 1 interrupt.the status of these hardware functions are checked by the status of the global variable in the main program and accordingly the task is done.the values of global variable gets set with the continuous polling of status of pins in 5 ms interrupt routine.
The serial port job is only to get the data and to transmit the data without loosing any of it and therefore has been provided the top priority.
Now I have two arrays of 200 bytes size each for the serial port.
Now the problem which I am getting is that my global variables values are getting set in the program which is a very abnormal behaviour.
Actually this is like this suppose I have a logic like this:
Initialize(void)
{
MsgCtr = 0;
...................
.......................
}
if(MsgCtr!=0)
{
MsgCtr --;
...............
............... do so and so
}
and
if(WorkCode == 6)
{
MsgCtr = 11;
}
SO what here has to happen actually is that the message counter variable gets initialized only when workcode condition gets satisfied and rest of time it remains 0.
but in my code when I saw in the debugger mode I got that the value
of the message counter variable gets set without entering into the workcode which is impossible case as this is the only route to change or initialise the MsgCtr t0 11.
What I got is that it gets initialised to some garbage variables randomly like sometimes to 0x64 or to 0xFF or to 0x04 and so on as many times I run the debugger.
So can you tell me that why this is happening actually.
why my global variables locations are not safe and picks up the garbage values without any logic.
Thanks
I have encountered some very serious problem in MG84FG516 controller using the Keil C51 compiler.
In my code I am using three interrupts in the priority as follows:
1 - Serial port 0
2 - Timer 0 to generate 300 us interrupt.
3 - Timer 1 to generate 5 ms interrupt.
Actually there are few functions like keypad scanning , battery power checkup, and other hardware related functionalities which are carried out in the 5 ms timer 1 interrupt.the status of these hardware functions are checked by the status of the global variable in the main program and accordingly the task is done.the values of global variable gets set with the continuous polling of status of pins in 5 ms interrupt routine.
The serial port job is only to get the data and to transmit the data without loosing any of it and therefore has been provided the top priority.
Now I have two arrays of 200 bytes size each for the serial port.
Now the problem which I am getting is that my global variables values are getting set in the program which is a very abnormal behaviour.
Actually this is like this suppose I have a logic like this:
Initialize(void)
{
MsgCtr = 0;
...................
.......................
}
if(MsgCtr!=0)
{
MsgCtr --;
...............
............... do so and so
}
and
if(WorkCode == 6)
{
MsgCtr = 11;
}
SO what here has to happen actually is that the message counter variable gets initialized only when workcode condition gets satisfied and rest of time it remains 0.
but in my code when I saw in the debugger mode I got that the value
of the message counter variable gets set without entering into the workcode which is impossible case as this is the only route to change or initialise the MsgCtr t0 11.
What I got is that it gets initialised to some garbage variables randomly like sometimes to 0x64 or to 0xFF or to 0x04 and so on as many times I run the debugger.
So can you tell me that why this is happening actually.
why my global variables locations are not safe and picks up the garbage values without any logic.
Thanks