apsua
Member level 3
Hello,
I have an array defined as below:
When I add one more element in it, it gives stack underflow error on both Proteus and also in real simulation. New code is as below:
Only one more PRIORITY_HIGH element is added to array. I made debug on the code on Proteus, the reset occurs at the line shown below:
When the code "shift_right" processed, every time, the stack pointer is decreased, till around 0x0060.
Can anyone please give a hint about this to me?
Note: It happens in also when I place the mcu to my controller board, too.
Thanks.
I have an array defined as below:
Code:
int messagePriorityLevels[] = {NO_PRIORITY,
NO_PRIORITY,
NO_PRIORITY,
NO_PRIORITY,
NO_PRIORITY,
PRIORITY_LOW,
PRIORITY_HIGH,
PRIORITY_HIGH,
PRIORITY_HIGH,
PRIORITY_HIGH,
PRIORITY_HIGH,
PRIORITY_LOW,
PRIORITY_HIGH,
PRIORITY_MID,
PRIORITY_MID,
PRIORITY_HIGH,
PRIORITY_HIGH,
PRIORITY_HIGH,
PRIORITY_HIGH,
PRIORITY_HIGH,
PRIORITY_MID,
PRIORITY_MID,
PRIORITY_LOW,
PRIORITY_HIGH,
};
When I add one more element in it, it gives stack underflow error on both Proteus and also in real simulation. New code is as below:
Code:
int messagePriorityLevels[] = {NO_PRIORITY,
NO_PRIORITY,
NO_PRIORITY,
NO_PRIORITY,
NO_PRIORITY,
PRIORITY_LOW,
PRIORITY_HIGH,
PRIORITY_HIGH,
PRIORITY_HIGH,
PRIORITY_HIGH,
PRIORITY_HIGH,
PRIORITY_LOW,
PRIORITY_HIGH,
PRIORITY_MID,
PRIORITY_MID,
PRIORITY_HIGH,
PRIORITY_HIGH,
PRIORITY_HIGH,
PRIORITY_HIGH,
PRIORITY_HIGH,
PRIORITY_MID,
PRIORITY_MID,
PRIORITY_LOW,
PRIORITY_HIGH,
PRIORITY_HIGH
};
Only one more PRIORITY_HIGH element is added to array. I made debug on the code on Proteus, the reset occurs at the line shown below:
Code:
void ShiftToRecords(int8 *ptr, int8 iterNum, int1 comType)
{
iterNum++;
blankShiftNumber = 24 - iterNum;
while(iterNum != 0)
{
shiftBit = shift_right(inputRecordsStable, 3, 0);
shift_right(ptr, 3, shiftBit);
iterNum--;
}
while(blankShiftNumber != 0)
{
shift_right(ptr, 3, 0); /* **** The reset evet happens in this line **** */
blankShiftNumber--;
}
inputRecordsStable[0] = 0;
inputRecordsStable[1] = 0;
inputRecordsStable[2] = 0;
return;
}
When the code "shift_right" processed, every time, the stack pointer is decreased, till around 0x0060.
Can anyone please give a hint about this to me?
Note: It happens in also when I place the mcu to my controller board, too.
Thanks.