I have configured a pin ( P1.2 Button S1 of kit mini 868 CC1110F32) on falling edge with interrupt, and this interrupt function start the watchdog (to have internal reset), because if you use external pin reset , the connection with debugger will be lost immediatly.
If you are debugging the code and watchdog generate an internal reset, you lost some data or something of wrong happens !!
Check this code, press run then stop, put a breakpoint on "a++" press run again and now push S1 Button(P1.2), the variable "a" become 1, but when the code reach the breakpoint (on a++ ), the program stop at address 0xFFFF address and next step is again new reset.
So become impossible to debug the code when you get a reset.
I think is a problem of CCdebugger.... it's possible to fix it ?
void main (void)
{
unsigned int a = 0;
SLEEP &= ~0x04; // power down osc
while( !( SLEEP & 0x40 ) ); /* wait for high speed crystal to become stable */
CLKCON = 0x00; /* switch from RC oscillator to high speed crystal oscillator */
Ext_Int_Init (); // external interrupt P1. external reset
EA = 1; // enable global interrupt
a = 1;
a ++;
while ( 1 );
}
void Ext_Int_Init ( void )
{
PICTL &= ~0x02; // interrupt enable on rising edge on port1
P1IEN |= 0x04; // enable interrupt on p1.2 (S1 of KIT)
IEN2 |= 0x10; // P1IE = 1
P1IFG = 0x00; // clear port1 status flag
P1IF = 0; // clear interrupt flag
WDCTL = 0x03; // watchdog counter at 64period 1.953 ms
}
void ExtInt_Reset ( void ) interrupt 15
{
if ( P1IFG & 0x04 ) // Pin to check
{
EA = 0;
P1IFG &= ~0x04; //
WDCTL |= 0x08; // start watchdog
while ( 1 ); // wait reset
}
else
{
uint8_t pio = 0; // check for other flag
}
}