I was working on interfacing a SmartCard and using interrupts and clock pulses and stuff. Then my Axon started acting all wierd and resetting. After some sleuthing I found the problem to be interrupts.
When I disable interrupts the axon does not reset. However if I don't disable interrupts then it constantly resets. I've commented out uartInit and rprintfInit as well as all the timer stuff, but no matter what I do if I don't put cli() then it will reset.
Any ideas how to fix this problem?
EDIT: Battery is fully charged and I double checked fuse settings - everything checks out.
Take a look this stripped down code:
int main(void)
{
int i=0;//useless variable
int j=0;//useless variable
/****************INITIALIZATIONS*******************/
uartInit(); // initialize the UART (serial port)
uartSetBaudRate(0, 4800); // set UARTE speed, for Bluetooth before was 115200
uartSetBaudRate(1, 115200); // set UARTD speed, for USB connection
uartSetBaudRate(2, 9600);
uartSetBaudRate(3, 115200); // set UARTJ speed, for Blackfin
rprintfInit(uart1SendByte);// initialize rprintf system and configure uart1 (USB) for rprintf
// initialize the timer system (comment out ones you don't want)
// disable all these !!!
timer0Init();
timer1Init();
// timer2Init();
// timer3Init();
// timer4Init();
//timer5Init();
configure_ports(); // configure which ports are analog, digital, etc.
a2dInit(); // initialize analog to digital converter (ADC)
a2dSetPrescaler(ADC_PRESCALE_DIV32); // configure ADC scaling
a2dSetReference(ADC_REFERENCE_AVCC); // configure ADC reference voltage
LED_on();
rprintf("\r\nSystem Warming Up");
//let system stabelize for X time
for(i=0;i<=16;i++)
{
delay_cycles(5000);
rprintf(".");
}
delay_cycles(6000);
//read each ADC once to get it working accurately
for(i=0;i<16;i++)
{
j=a2dConvert8bit(i);
}
LED_off();
/**************************************************/
rprintf("Initialization Complete \r\n");
cli(); // disable interrupts. if this is commented out then the Axon resets
while(!button_pressed()); //wait until user pushes button
while(1) {
control();
delay_cycles(100);
}
return 0;
}