Here, in particular:
while(1) { // this is the main loop
if (timer == 2) {
// timed code here....
shiftFwd(&H_GREEN_data[0]);
shiftFwd(&H_BLUE_data[0]);
timer=0;
}
You are waiting for the ISR to fire anyway, and when it does you will have a few clocks before you notice if timer == 2. So add a sleep:
while(1) { // this is the main loop
sleep_mode (); // wake in a predictable way
if (timer == 2) {
// timed code here....
shiftFwd(&H_GREEN_data[0]);
shiftFwd(&H_BLUE_data[0]);
timer=0;
}
In initialization, make sure sleep mode is idle:
set_sleep_mode (SLEEP_MODE_IDLE);