Hi Freaks,
I have the following code:
void main(void) { unsigned char ResetSrc = MCUSR; // save reset source MCUSR = 0x00; // cleared for next reset detection ... // further initialisation if (ResetSrc & PORF) cputs("PWR RESET\n\r"); if (ResetSrc & EXTRF) cputs("EXT RESET\n\r"); if (ResetSrc & BORF) cputs("BOD RESET\n\r"); if (ResetSrc & WDRF) cputs("WDT RESET\n\r"); ... //rest of code
Problem is that I don't seem to be able to generate a POR on its own. I always get a POR followed by a BOR. The code would suggest that both the POR and BOR are set. BORF is supposed to be cleared by a POR.
I can trigger a BOR on its own and a EXT on its own but POR is always followed by the BOR.
I cannot believe that I have such a slow rising VCC that the system exits POR and then jumps into BOR before I have the chance to execute the clear MCUSR. I guess it could occur during ICCs auto generated initialisation code but I'm reluctant to believe it.
Anyone able to shed some light on this? Am I doing something wrong? Am I missing some thing?
Thanks
Steve