Skip to content

Commit ec7a3fe

Browse files
authored
Redid formula for calculating subticks
changed subticks calculation to give a range from 0 to 32767.
1 parent d8bb2d7 commit ec7a3fe

File tree

1 file changed

+2
-2
lines changed
  • ports/esp32s2/supervisor

1 file changed

+2
-2
lines changed

ports/esp32s2/supervisor/port.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ uint64_t port_get_raw_ticks(uint8_t* subticks) {
119119
struct timeval tv_now;
120120
gettimeofday(&tv_now, NULL);
121121
// convert usec back to ticks
122-
uint64_t all_subticks = (uint64_t)tv_now.tv_usec / 1024;
122+
uint64_t all_subticks = (uint64_t)(tv_now.tv_usec * 2) / 71;
123123
if (subticks != NULL) {
124124
*subticks = all_subticks % 32;
125125
}
126-
return (uint64_t)tv_now.tv_sec * 1024L + all_subticks;
126+
return (uint64_t)tv_now.tv_sec * 1024L + all_subticks / 32;
127127
}
128128

129129
// Enable 1/1024 second tick.

0 commit comments

Comments
 (0)