[info]
name = "TIMER0"
desc = "8-Bit Timer/Counter0 with PWM"
[[int]]
name = "TIMER0_COMPA"
desc = "Timer/Counter0 Compare Match A"
vect = 21
[[int]]
name = "TIMER0_COMPB"
desc = "Timer/Counter0 Compare Match B"
vect = 22
[[int]]
name = "TIMER0_OVF"
desc = "Timer/Counter0 Overflow"
vect = 23
[val.com]
values = [
{valu=0, name="DISCONNECTED", desc="Normal port operation, OC0x disconnected"},
{valu=1, name="MATCH_TOGGLE", desc="Toggle OC0x on Compare Match (Might depend on WGM)"},
{valu=2, name="MATCH_CLEAR", desc="Clear OC0x on Compare Match (If PWM is enabled, OC0x is set at TOP)"},
{valu=3, name="MATCH_SET", desc="Set OC0x on Compare Match (If PWM is enabled, OC0x is cleared at TOP)"},
]
[val.wgm]
values = [
{valu=0, name="NORMAL_TOP", desc="Normal, Top: `0xff`, Update: *Immediate*, Flag: *MAX*"},
{valu=1, name="PWM_PHASE", desc="Phase Correct PWM, Top: `0xff`, Update: *TOP*, Flag: *BOTTOM*"},
{valu=2, name="CTC", desc="CTC, Top: *OCRA*, Update: *Immediate*, Flag: *MAX*"},
{valu=3, name="PWM_FAST", desc="Fast PWM, Top: `0xff`, Update: *TOP*, Flag: *MAX*"},
]
[val.cs]
values = [
{valu=0, name="STOPPED", desc="No clock source (Timer/Counter stopped)"},
{valu=1, name="IO", desc="clkIO/1 (No prescaling)"},
{valu=2, name="IO_8", desc="clkIO/8 (From prescaler)"},
{valu=3, name="IO_64", desc="clkIO/64 (From prescaler)"},
{valu=4, name="IO_256", desc="clkIO/256 (From prescaler)"},
{valu=5, name="IO_1024", desc="clkIO/1024 (From prescaler)"},
{valu=6, name="EXT_FALLING", desc="External clock source on T0 pin. Clock on falling edge."},
{valu=7, name="EXT_RISING", desc="External clock source on T0 pin. Clock on rising edge."},
]
#---------------------------------------------------------------------#
[[reg]]
name = "TIFR"
desc = "Timer Interrupt Flag Register"
addr = "0x35"
fields = [
{name="OCF_B", desc="Output Compare B Match Flag", rnge="2:2"},
{name="OCF_A", desc="Output Compare A Match Flag", rnge="1:1"},
{name="TOV", desc = "Timer Overflow Flag", rnge="0:0"},
]
#---------------------------------------------------------------------#
[[reg]]
name = "TCCR_A"
desc = "Timer/Counter Control Register A"
addr = "0x44"
fields = [
{name="COM_A", desc="Compare Match Output A Mode", rnge="7:6", valu="com"},
{name="COM_B", desc="Compare Match Output B Mode", rnge="5:4", valu="com"},
{name="WGM0", desc="Waveform Generation Mode Bits 1:0", rnge="1:0", valu="wgm"},
]
#---------------------------------------------------------------------#
[[reg]]
name = "TCCR_B"
desc = "Timer/Counter Control Register B"
addr = "0x45"
fields = [
{name="FOC_A", desc="Force Output Compare A", rnge="7:7", cstm="write-only"},
{name="FOC_B", desc="Force Output Compare B", rnge="6:6", cstm="write-only"},
{name="WGM2" , desc="Waveform Generation Mode Bit 2 (Enable Top: *OCRA* for PWM modes)", rnge="3:3"},
{name="CS" , desc="Clock Select", rnge="2:0", valu="cs"},
]
#---------------------------------------------------------------------#
[[reg]]
name = "TCNT"
desc = "Timer/Counter Register"
addr = "0x46"
safe = true
#---------------------------------------------------------------------#
[[reg]]
name = "OCR_A"
desc = "Timer Output Compare Register A"
addr = "0x47"
safe = true
#---------------------------------------------------------------------#
[[reg]]
name = "OCR_B"
desc = "Timer Output Compare Register B"
addr = "0x48"
safe = true
#---------------------------------------------------------------------#
[[reg]]
name = "TIMSK"
desc = "Timer Interrupt Mask Register"
addr = "0x6E"
fields = [
{name="OCIE_B", desc="Output Compare Match B Interrupt Enable", rnge="2:2"},
{name="OCIE_A", desc="Output Compare Match A Interrupt Enable", rnge="1:1"},
{name="TOIE", desc="Timer Overflow Interrupt Enable", rnge="0:0"},
]