When using a 16-bit device, an unexpected Reset occurred. How do I determine what caused it?
Some things to consider:
• To determine a Reset source, check the RCON register.
• Handle traps/interrupts in an Interrupt Service Routine (ISR). You should include trap.c style code, for
example,
void __attribute__((__interrupt__)) _OscillatorFail(void);
:
void __attribute__((__interrupt__)) _AltOscillatorFail(void);
:
void __attribute__((__interrupt__)) _OscillatorFail(void)
{
INTCON1bits.OSCFAIL = 0; //Clear the trap flag
while (1);
}
:
void __attribute__((__interrupt__)) _AltOscillatorFail(void)
{
INTCON1bits.OSCFAIL = 0;
while (1);
}
:
• Use ASSERTs. For example: ASSERT (IPL==7)
Frequently Asked Questions
© 2020 Microchip Technology Inc.
User Guide
DS50002751D-page 37