Skip to content

Commit 062c8d7

Browse files
author
Virgil Dupras
committed
Fix timer1 on tinyx5
The prescaler list for timer1 on the tinyx5 was incomplete. Moreover, having no WGM data made the timer run in `avr_timer_wgm_none`, with a zero size (it would overflow all the time). Setting a default wgm_op makes time timer run in normal mode witha size of 8 bits.
1 parent b3a8e8f commit 062c8d7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

simavr/cores/sim_tinyx5.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,13 @@ const struct mcu_t SIM_CORENAME = {
200200
},
201201
.timer1 = {
202202
.name = '1',
203-
// no wgm bits
203+
// timer1 has no wgm bits, but we still need to define a wgm op so that
204+
// we can set a proper kind/size to the timer
205+
.wgm_op = {
206+
[0] = AVR_TIMER_WGM_NORMAL8(),
207+
},
204208
.cs = { AVR_IO_REGBIT(TCCR1, CS10), AVR_IO_REGBIT(TCCR1, CS11), AVR_IO_REGBIT(TCCR1, CS12), AVR_IO_REGBIT(TCCR1, CS13) },
205-
.cs_div = { 0, 0, 1 /* 2 */, 2 /* 4 */, 3 /* 8 */, 4 /* 16 */ },
209+
.cs_div = { 0, 0, 1 /* 2 */, 2 /* 4 */, 3 /* 8 */, 4 /* 16 */, 5 /* 32 */, 6 /* 64 */, 7 /* 128 */, 8 /* 256 */, 9 /* 512 */, 10 /* 1024 */, 11 /* 2048 */, 12 /* 4096 */, 13 /* 8192 */, 14 /* 16384 */ },
206210

207211
.r_tcnt = TCNT1,
208212

0 commit comments

Comments
 (0)