8000 port/rp2: Make tickless, remove 1ms timeout when idle. · micropython/micropython@f5e3250 · GitHub
[go: up one dir, main page]

Skip to content

Commit f5e3250

Browse files
committed
port/rp2: Make tickless, remove 1ms timeout when idle.
The main motivation for doing this was to reduce the latency when the system is woken by a USB interrupt. The best_effort_wfe_or_timeout() function calls into the pico-sdk dynamic timer framework which sets up a new dynamic timer instance each time, and then has to tear it down before continuing after a WFE. Testing Python interrupt latency it seems to improved by about 12us (from average of 46us to 34us running a Pin IRQ). C-based "scheduled nodes" should see even lower latency. The risk with this change is that it exposes cases where a driver expects execution to continue without an interrupt. Alternative is to enable the standard ARM SysTick interrupt to wake the CPU at tick intervals. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
1 parent a614c1d commit f5e3250

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

ports/rp2/modmachine.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ STATIC mp_obj_t machine_freq(size_t n_args, const mp_obj_t *args) {
111111
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_freq_obj, 0, 1, machine_freq);
112112

113113
STATIC mp_obj_t machine_idle(void) {
114-
best_effort_wfe_or_timeout(make_timeout_time_ms(1));
114+
__wfe();
115115
return mp_const_none;
116116
}
117117
STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_idle_obj, machine_idle);

ports/rp2/mpconfigport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ extern void mp_thread_end_atomic_section(uint32_t);
274274
#define MICROPY_EVENT_POLL_HOOK \
275275
do { \
276276
MICROPY_EVENT_POLL_HOOK_FAST; \
277-
best_effort_wfe_or_timeout(make_timeout_time_ms(1)); \
277+
__wfe(); \
278278
} while (0);
279279

280280
#define MICROPY_MAKE_POINTER_CALLABLE(p) ((void *)((mp_uint_t)(p) | 1))

0 commit comments

Comments
 (0)
0