CPU used in an RP2 with _thread and timer #10371
-
Target platform is the Raspberry Pi Pico. Is there a way to know what CPU is used from inside a method? I want to have one thread running a realtime routine and the other running nonrealtime stuff (mostly user interface related). The realtime part of the code should look like this (a bit more involved though :
I understood the Timer class in RP2 is software based, will an instance of it run in the same CPU as the thread? I instantiate two timers, one per thread, will they run in their respective CPU and not be hindered by each other? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
On the RPi Pico you have up to 2 threads that run on the two cores in parallel. As soon as you start another thread with
Not with |
Beta Was this translation helpful? Give feedback.
On the RPi Pico you have up to 2 threads that run on the two cores in parallel. As soon as you start another thread with
_thread.start_new_thread(thread_func, (arg0))
this will employ the second core. Attempting to start yet another thread will raise an Error of too many threads. This is because your MP interpreter is the first thread, so to say, and there are only the two threads each on it's core.Not with
_thread
. There is a rudimentary port ofthreading
in micropython-lib which at the cost of overhead implements a Thread class with many more functions, perhaps also a core function. If not, you may extend it, as you see t…