Hi All,
While working with MC9S08DZ32 unit I found some strange issue.
Have a look at the function causing the problem:
U8 eepromSaveAll(EEPROM_DATA_BLOCK * paramBlock,EEPROM_TAddress epp_address){ U8 status; U8 i = 0; U8 size = sizeof(EEPROM_DATA_BLOCK); byte Array[sizeof(EEPROM_DATA_BLOCK)]; (void)memcpy(Array,paramBlock,sizeof(EEPROM_DATA_BLOCK)); while(size) { status = EEPROM_SetByte(epp_address++,Array[i]); size--; i++; } return status;
It is causing heavy instability of the system. Every call or every second call causes device reset.
Interesting thing is that when Array array is declared with static the problem disappears:
static byte Array[sizeof(EEPROM_DATA_BLOCK)];
I have had no time to investigate that more deeply. Problem is solved but curosity remains
Any ideas?
Solved! Go to Solution.
How big is EEPROM_DATA_BLOCK and how big is your stack? Nonstatic Array is allocated on stack...
EEPROM_DATA_BLOCK is 42 bytes. Stack is 128 bytes. There's a lot code inside so probably stack is overflown. I will have a look at it later but it seems to be clear for me now.
Thanks!
Problem solved. Stack overflow...