I have part of an ISR timer section on an Xmega to do a simple slow blink...What I created works 100% completely fine. However, I somewhat don't like the fact that the port is always written every isr cycle (whether needed or not, seems wasteful). If I put in more conditionals or logic, I might avoid that, but then the extra logic seems to take as just as much time. None of the values are fixed (other than "4"), since the freq & width are changed (elsewhere) depending on various modes. The actual timing values are not extremely critical (such as being off a few counts). Any thoughts?
...isr stuff... ...more isr stuff... green_time++; if (green_width<green_time) PORTE_Virt.OUT &= ~GRN_LED_PE; //LED turned OFF else PORTE_Virt.OUT |= GRN_LED_PE; //LED turned ON if (green_time>green_period) green_time=0; //Period is used up