kinetis:drv_io_timer ensure the Mod register is updated

This commit is contained in:
David Sidrane
2017-09-27 14:41:24 -10:00
parent ccc83dde33
commit 1615d5642e
+7 -2
View File
@@ -456,11 +456,16 @@ static int allocate_channel(unsigned channel, io_timer_channel_mode_t mode)
static int timer_set_rate(unsigned timer, unsigned rate)
{
irqstate_t flags = px4_enter_critical_section();
uint32_t save = rSC(timer);
rSC(timer) = save & ~(FTM_SC_CLKS_MASK);
/* configure the timer to update at the desired rate */
rMOD(timer) = (BOARD_PWM_FREQ / rate) - 1;
rSC(timer) = save;
/* generate an update event; reloads the counter and all registers */
rSYNC(timer) = FTM_SYNC;
px4_leave_critical_section(flags);
return 0;
}