Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made safer reset of timer #12442

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/drivers/stm32/drv_io_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@
#else
#define CCER_C1_INIT GTIM_CCER_CC1E
#endif

#define CNT_VALUE_SAFE_TO_WRITE ((unsigned int)3000 * 1000000/BOARD_ONESHOT_FREQ)

// NotUsed PWMOut PWMIn Capture OneShot Trigger
io_timer_channel_allocation_t channel_allocations[IOTimerChanModeSize] = { UINT8_MAX, 0, 0, 0, 0, 0 };

Expand Down Expand Up @@ -505,7 +508,7 @@ void io_timer_trigger(void)
if (validate_timer_index(timer) == 0) {
int channels = get_timer_channels(timer);

if (oneshots & channels) {
if (oneshots & channels & (rCNT(timer) > CNT_VALUE_SAFE_TO_WRITE)) {
action_cache[actions++] = io_timers[timer].base;
}
}
Expand Down