[7] = AVR_TIMER_WGM_FASTPWM10(),
// TODO: 8, 9 PWM phase and freq correct ICR & 10, 11
[12] = AVR_TIMER_WGM_ICCTC(),
- [14] = AVR_TIMER_WGM_ICPWM(),
+ [14] = AVR_TIMER_WGM_ICFASTPWM(),
[15] = AVR_TIMER_WGM_OCPWM(),
},
.cs = { AVR_IO_REGBIT(TCCR1B, CS10), AVR_IO_REGBIT(TCCR1B, CS11), AVR_IO_REGBIT(TCCR1B, CS12) },
// 10
// 11
[12] = AVR_TIMER_WGM_ICCTC(),
- [14] = AVR_TIMER_WGM_ICPWM(),
+ [14] = AVR_TIMER_WGM_ICFASTPWM(),
[15] = AVR_TIMER_WGM_OCPWM(),
},
.cs = { AVR_IO_REGBIT(TCCR3B, CS30), AVR_IO_REGBIT(TCCR3B, CS31), AVR_IO_REGBIT(TCCR3B, CS32) },
[7] = AVR_TIMER_WGM_FASTPWM10(),
// TODO: 8, 9 PWM phase and freq correct ICR & 10, 11
[12] = AVR_TIMER_WGM_ICCTC(),
- [14] = AVR_TIMER_WGM_ICPWM(),
+ [14] = AVR_TIMER_WGM_ICFASTPWM(),
[15] = AVR_TIMER_WGM_OCPWM(),
},
.cs = { AVR_IO_REGBIT(TCCR4B, CS40), AVR_IO_REGBIT(TCCR4B, CS41), AVR_IO_REGBIT(TCCR4B, CS42) },
[7] = AVR_TIMER_WGM_FASTPWM10(),
// TODO: 8, 9 PWM phase and freq correct ICR & 10, 11
[12] = AVR_TIMER_WGM_ICCTC(),
- [14] = AVR_TIMER_WGM_ICPWM(),
+ [14] = AVR_TIMER_WGM_ICFASTPWM(),
[15] = AVR_TIMER_WGM_OCPWM(),
},
.cs = { AVR_IO_REGBIT(TCCR5B, CS50), AVR_IO_REGBIT(TCCR5B, CS51), AVR_IO_REGBIT(TCCR5B, CS52) },
_timer_get_ocr(p, AVR_TIMER_COMPA) : _timer_get_icr(p);
avr_timer_configure(p, p->cs_div_value, top, reset);
} break;
- case avr_timer_wgm_fast_pwm:
- avr_timer_configure(p, p->cs_div_value, p->wgm_op_mode_size, reset);
- break;
+ case avr_timer_wgm_fast_pwm: {
+ uint16_t top =
+ (p->mode.top == avr_timer_wgm_reg_icr) ? _timer_get_icr(p) :
+ p->wgm_op_mode_size;
+ avr_timer_configure(p, p->cs_div_value, top, reset);
+ } break;
case avr_timer_wgm_none:
avr_timer_configure(p, p->cs_div_value, p->wgm_op_mode_size, reset);
break;
#define AVR_TIMER_WGM_FCPWM10() { .kind = avr_timer_wgm_fc_pwm, .size=10 }
#define AVR_TIMER_WGM_OCPWM() { .kind = avr_timer_wgm_pwm, .top = avr_timer_wgm_reg_ocra }
#define AVR_TIMER_WGM_ICPWM() { .kind = avr_timer_wgm_pwm, .top = avr_timer_wgm_reg_icr }
+#define AVR_TIMER_WGM_ICFASTPWM() { .kind = avr_timer_wgm_fast_pwm, .top = avr_timer_wgm_reg_icr }
typedef struct avr_timer_comp_t {
avr_int_vector_t interrupt; // interrupt vector