I'm trying to update the arduino software on this device we are using. Downloaded the latest development environment and built for my target. Compiles, no problem. But when I load code the device just continuously resets.
I managed to tear everything down and isolate the problem to the setup function. Looks like it is occurring somewhere between disable interrupt, setup interrupt registers and re-enabling interrupts.
NOW, the interesting thing is, this problem does not occur in the Arduino 1.0.x IDE, but it does occur with the latest official build as well as the nightly build. All of which are the 64bit linux version, if that makes any difference.
Best I can make out, updates to interrupt.h or another include have brought out an error in how things are setup. I could spend a good amount of time digging through this, but was hoping someone w/ a trained eye could spot any mistakes in the code below:
//-----------------------------------------------------------------------------
void setup()
{
.... some other stuff here....
__ // *** INITIALIZE TIMER INTERRUPTS ******************************************__
** // Disable interrupts**
** cli();**
** // Clear timer1 control registers**
** TCCR1A = 0;**
** TCCR1B = 0;**
** // Initialize counter to 0 **
** TCNT1 = 0; **
** // Set compare match register to default sample rate**
__ OCR1A = 16000000 / (sampleRate * 1024) - 1;__
** // Turn on CTC Mode**
** TCCR1B |= (1 << WGM12);**
** // Set prescaler to 1024**
** TCCR1B |= (1 << CS12) | (1 << CS10);**
** // Enable timer compare interrupt**
** TIMSK1 |= (1 << OCIE1A);**
** // Clear timer2 control registers**
** TCCR2A = 0;**
** TCCR2B = 0;**
** // Initialize counter to 0**
** TCNT2 = 0;**
** // Set compare match register for sample rate of 1000Hz**
** OCR2A = 250;**
** OCR2B = 250;**
** // Turn on CTC Mode**
** TCCR2B |= (1 << WGM22);**
** // Set prescaler to 64**
** TCCR2B |= (1 << CS22) | (0 << CS21) | (0 << CS20);**
** // Enable timer compare interrupt**
** TIMSK2 |= (1 << OCIE2A);**
** // Enable interrupts**
** sei();**
}