diff --git a/stmhal/main.c b/stmhal/main.c index ebab885091..7bf6f6a3af 100644 --- a/stmhal/main.c +++ b/stmhal/main.c @@ -454,7 +454,9 @@ int main(void) { #endif // basic sub-system init + #if MICROPY_PY_THREAD pyb_thread_init(&pyb_thread_main); + #endif pendsv_init(); led_init(); #if MICROPY_HW_HAS_SWITCH diff --git a/stmhal/stm32_it.c b/stmhal/stm32_it.c index a6503d3100..4dddc5e0ba 100644 --- a/stmhal/stm32_it.c +++ b/stmhal/stm32_it.c @@ -289,10 +289,12 @@ void SysTick_Handler(void) { dma_idle_handler(uwTick); } + #if MICROPY_PY_THREAD // signal a thread switch at 4ms=250Hz if (pyb_thread_enabled && (uwTick & 0x03) == 0x03) { SCB->ICSR = SCB_ICSR_PENDSVSET_Msk; } + #endif } /******************************************************************************/