Skip to content

Commit 8d8e833

Browse files
author
ga
committed
Add WGM bits and modes for Counter/Timer 0 in ATMega16 and ATMega32.
Patch by user GeorgKorger for Issue #538.
1 parent 132cc67 commit 8d8e833

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

simavr/cores/sim_megax.h

+10
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,20 @@ const struct mcu_t SIM_CORENAME = {
166166
},
167167
.timer0 = {
168168
.name = '0',
169+
#ifdef OC0_PORT
170+
.wgm = { AVR_IO_REGBIT(TCCR0, WGM00), AVR_IO_REGBIT(TCCR0, WGM01)},
171+
.wgm_op = {
172+
[0] = AVR_TIMER_WGM_NORMAL8(),
173+
// TODO: 1 PWM phase correct 8bit
174+
[2] = AVR_TIMER_WGM_CTC(),
175+
[3] = AVR_TIMER_WGM_FASTPWM8(),
176+
},
177+
#else
169178
.wgm_op = {
170179
[0] = AVR_TIMER_WGM_NORMAL8(),
171180
// CTC etc. are missing because atmega8 does not support them on timer0
172181
},
182+
#endif
173183
.cs = { AVR_IO_REGBIT(TCCR0, CS00), AVR_IO_REGBIT(TCCR0, CS01), AVR_IO_REGBIT(TCCR0, CS02) },
174184
.cs_div = { 0, 0, 3 /* 8 */, 6 /* 64 */, 8 /* 256 */, 10 /* 1024 */, AVR_TIMER_EXTCLK_CHOOSE, AVR_TIMER_EXTCLK_CHOOSE /* AVR_TIMER_EXTCLK_CHOOSE means External clock chosen*/},
175185

0 commit comments

Comments
 (0)