Essentially, the aim of the piece of test code is to: *Start a timer (hardware timer) - turn on two LEDs - wait until the timer finishes - turn off both LEDs - delay for 0.9s - start again.
for (;;) //forever
{
PORTB &= ~_BV(PINB7); //Turn OFF GREEN LED
_delay_ms(900); //RED LED stay off for 0.9s
timer_two(); // start 5 second timer
while(!(TIFR1 & _BV(OCF1A))) //WHILE 5 second timer flag is not set
{
PORTB |= _BV(PINB7); //Turn on GREEN LED
PORTA |= _BV(PINA6); //Turn on RED LED
} //leave while loop when five second timer flag is set
PORTA &= ~_BV(PINA6); //Turn off RED LED #THIS DOESN'T HAPPEN#
}
However, with the code written as it is, both LEDs turn on, but only the Green LED turns off. The Green LED continues to turn on and off as I expected.
Although it clearly exits the while loop (as it turns the Green LED off), it doesn't seem to execute anything after it.
Am I missing a basic trick here?
(Code is compiled for an AVR, atmega644p via avr-gcc, on Windows)