#include BOARD_H
#define REFERENCE bandgap
#define EDGE falling
#define COUNTER counter0
#define COUNTER_CLK_DIV 64
#define COMPARE compare0
#define ON_TIME 0.001
#define ON_TIME_COUNT ON_TIME * HW_SYSHZ / COUNTER_CLK_DIV
HW_ISR( (COUNTER,COMPARE,irq) )
{
hw( disable, (COUNTER,COMPARE,irq) );
hw( clear, (acmp0,irq) );
hw( enable, (acmp0,irq) );
}
{
hw( disable, (acmp0,irq) );
if ( COUNTER_CLK_DIV > 1 )
hw( turn, (COUNTER,prescaler0), off );
if ( COUNTER_CLK_DIV > 1 )
hw( turn, (COUNTER,prescaler0), on);
hw( clear, (COUNTER,COMPARE,irq) );
hw( enable, (COUNTER,COMPARE,irq) );
}
int main ( )
{
sleep, enabled,
sleep_mode, idle );
hwa( configure, PIN_LED, mode, digital_output );
#if HW_ADDRESS(REFERENCE) != -1
hwa( configure, REFERENCE,
mode, analog_input );
#endif
mode, analog_input );
if ( ON_TIME_COUNT > ((1UL<<
HW_BITS(COUNTER))-1) )
HWA_E(
"COUNTER can not afford ON_TIME.") ;
clock, ioclk / COUNTER_CLK_DIV,
direction, up_loop );
hwa( write, (COUNTER,COMPARE), ON_TIME_COUNT );
edge, EDGE,
positive_input, REFERENCE,
hwa( enable, (acmp0,irq) );
hw( enable, interrupts );
for(;;)
return 0 ;
}