Blink a LED using a counter overflow flag
 
 
#include BOARD_H
 
 
#define COUNTER                 counter0
#define CLKDIV                  64
#define COUNTMODE               up_loop
#define PERIOD                  0.5
 
#define STRCMP(s1,s2)           __builtin_strcmp(s1,s2)
 
 
int main ( )
{
  
 
  
  hwa( configure, PIN_LED, mode, digital_output );
 
 
  
       clock,     ioclk / CLKDIV,
       direction, COUNTMODE,
       bottom,    0,
       top,       compare0 );
  
  
  if ( !STRCMP(
HW_Q(COUNTMODE),
"updown_loop") )
 
    hwa( write, (COUNTER, compare0), (uint8_t)(0.5 + 0.001 * HW_SYSHZ / CLKDIV / 2) );
 
  else
    hwa( write, (COUNTER, compare0), (uint8_t)(0.5 + 0.001 * HW_SYSHZ / CLKDIV) );
 
 
  
 
  static uint8_t n ;
  for(;;) {
    if ( 
hw( read, (COUNTER,irq,overflow) ) ) {
 
      hw( clear, (COUNTER,irq,overflow) );
 
      n++ ;
      if ( n >= (uint8_t)(PERIOD / 2.0 / 0.001) ) {
        n = 0 ;
      }
    }
  }
}