Skip to content

Commit 9a1d864

Browse files
committed
overflowed tick counter needs 64 bits everywhere
1 parent 7e59ff3 commit 9a1d864

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

ports/atmel-samd/supervisor/port.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ uint32_t port_get_saved_word(void) {
431431
static volatile uint64_t overflowed_ticks = 0;
432432
static volatile bool _ticks_enabled = false;
433433

434-
static uint32_t _get_count(uint32_t* overflow_count) {
434+
static uint32_t _get_count(uint64_t* overflow_count) {
435435
#ifdef SAM_D5X_E5X
436436
while ((RTC->MODE0.SYNCBUSY.reg & (RTC_MODE0_SYNCBUSY_COUNTSYNC | RTC_MODE0_SYNCBUSY_COUNT)) != 0) {}
437437
#endif
@@ -500,7 +500,7 @@ void RTC_Handler(void) {
500500
}
501501

502502
uint64_t port_get_raw_ticks(uint8_t* subticks) {
503-
uint32_t overflow_count;
503+
uint64_t overflow_count;
504504
uint32_t current_ticks = _get_count(&overflow_count);
505505
if (subticks != NULL) {
506506
*subticks = (current_ticks % 16) * 2;

ports/nrf/supervisor/port.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ uint32_t port_get_saved_word(void) {
276276
uint64_t port_get_raw_ticks(uint8_t* subticks) {
277277
common_hal_mcu_disable_interrupts();
278278
uint32_t rtc = nrfx_rtc_counter_get(&rtc_instance);
279-
uint32_t overflow_count = overflow_tracker.overflowed_ticks;
279+
uint64_t overflow_count = overflow_tracker.overflowed_ticks;
280280
common_hal_mcu_enable_interrupts();
281281

282282
if (subticks != NULL) {

0 commit comments

Comments
 (0)