krüe :: avrforth :: timer


The atmega series contains two main type of timers: 8bit and 16bit. The avrforth timer driver attempts to treat both types as consistently as possible. All timer specific words begin with tx, where x is the timer number. Certain configuration constants are shared between all timers.


word stack description
txcnt ( -- a ) counter register
txovfint ( -- bit ) overflow interrupt enable
txovfflag ( -- bit ) overflow interrupt flag
'txovf ( -- a ) overflow interrupt vector
txclk ( x -- ) clock configuration
txwgm ( x -- ) waveform generation mode configuration
txocy ( -- a ) output compare register
txocyint ( -- bit ) output compare interrupt enable
tcocyflag ( -- bit ) output compare interrupt flag
'txocy ( -- a ) output compare interrupt vector
txocy ( x -- ) output compare pin action configuration
txic ( -- a ) input capture register
txicint ( -- bit ) input capture interrupt enable
txicflag ( -- bit ) input capture interrupt flag
'txic ( -- a ) input capture interrupt vector
txicf ( -- bit ) input capture noise cancelling filter enable
txice ( x -- ) input capture edge configuration


synchronous clock

These constants can be passed to txclk to control the clock configuration of synchronous timers.

asynchronous clock

These constants can be passed to txclk to control the clock configuration of timers with asynchronous ability (even if asynchronous mode is not used).

waveform generation mode

These constants can be passed txwgm to configure a timer's waveform generation mode.

output compare pin action

These constants can be passed to txocy to configure an output compare channel's compare action. y is the letter of the output compare channel. Timers with only one output compare channel still use the name txoca for consistency.

input compare edge

These constants can be passed to txice to configure an input capture channel's detection edge.