Skip to content

Commit f2eb77a

Browse files
committed
STM32_us_ticker_16b: reset counter when fire interrupt
Fixing regression introduced in commit "Ticker: add fire interrupt now function". In above mentioned commit, the management of timestamp being in the past has been moved to higher layer (hal/mbed_ticker_api.c), but the reset of oc_int was missing when implementing the new us_ticker_fire_interrupt function - which is fixed now.
1 parent 3e00a22 commit f2eb77a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

targets/TARGET_STM/us_ticker_16b.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ void us_ticker_set_interrupt(timestamp_t timestamp)
152152
*/
153153
uint32_t current_time = us_ticker_read();
154154
uint32_t delta = timestamp - current_time;
155+
/* Note: The case of delta <= 0 is handled in MBED upper layer */
155156
oc_int_part = (delta - 1) >> 16;
156157
if ( ((delta - 1) & 0xFFFF) >= 0x8000 &&
157158
__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET ) {
@@ -169,6 +170,9 @@ void us_ticker_set_interrupt(timestamp_t timestamp)
169170

170171
void us_ticker_fire_interrupt(void)
171172
{
173+
/* When firing the event, the number of 16 bits counter wrap-ups (oc_int)
174+
* must be re-initialized */
175+
oc_int_part = 0;
172176
HAL_TIM_GenerateEvent(&TimMasterHandle, TIM_EVENTSOURCE_CC1);
173177
}
174178

0 commit comments

Comments
 (0)