mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-06 16:49:51 +08:00
kinetis:drv_io_timer ensure the Mod register is updated
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user