Skip to content

Commit c17be7e

Browse files
committed
Fix possible overflow of NRF51 os tick.
The RTC1 counter can increase while the new value for the CC register used by the os tick is computed. As a result, when interrupts are enabled again RTC1 counter and CC register value are equal. If these two values are equal then the interrupt for the CC channel used by the OS tick will be generated the next time the RTC counter reach that value. In other words, the next OS tick will occur 131 seconds latter. This issue possibly concern all NRF51 targets with 32K of RAM but is only visible on NRF51_DK target when their is heavy BLE load.
1 parent 0712b8a commit c17be7e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

hal/targets/hal/TARGET_NORDIC/TARGET_NRF5/us_ticker.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ static void register_next_tick() {
474474
uint32_t current_counter = nrf_rtc_counter_get(COMMON_RTC_INSTANCE);
475475

476476
// If an overflow occur, set the next tick in COUNTER + delta clock cycles
477-
if (is_in_wrapped_range(previous_tick_cc_value, new_compare_value, current_counter) == false) {
477+
if (is_in_wrapped_range(previous_tick_cc_value, new_compare_value, current_counter + 1) == false) {
478478
new_compare_value = current_counter + delta;
479479
}
480480
nrf_rtc_cc_set(COMMON_RTC_INSTANCE, OS_TICK_CC_CHANNEL, new_compare_value);

0 commit comments

Comments
 (0)