ftrias / TeensyThreads

MIT License
182 stars 26 forks source link

Teensy 4 timeslice 5 ms #20

Closed manitou48 closed 4 years ago

manitou48 commented 4 years ago

With scope I noticed that Teensy 3* threads have 10 ms timeslice, but Teensy 4 has 5 ms timeslice?

I think the problem is that GPT ISR will fire twice unless you have asm volatile ("dsb"); at the end of the isr.

static void attribute((naked, noinline)) gpt1_isr() { GPT1_SR |= GPT_SR_OF1; // clear set bit asm volatile("dsb"); __asm volatile("b context_switch"); }

ftrias commented 4 years ago

Thanks for catching that. It's a subtle bug. I have commited your suggested fix.