I'm trying to get my Raspberry Pico W to do something on it's second processor core, but I'm not getting very far.
If I run this simple program,
import time, _thread, machine
pin = machine.Pin("LED", machine.Pin.OUT)
# lock = _thread.allocate_lock()
def core0():
counter = 0
while True:
print(counter)
counter += 2
time.sleep(2)
def core1():
counter = 1
while True:
print(counter)
counter += 2
# pin.toggle()
time.sleep(5)
thread1 = _thread.start_new_thread(core1, ())
core0()
I get the following (proper) output
10
2
4
3
6
8
5
10
12
14
7
16
18
But if I uncomment the pin.toggle() line, I observe the pin getting toggled once, and then it seems like the thread freezes, here is the output:
10
2
4
6
8
10
12
14
I also noticed that if I try to access the network, or wifi settings, that also "freezes" the thread.
How can I solve this issue?
Edit:
I just learned that the LED is connected to the wifi chip on the pico W, so I tested the same program with a GPIO pin, and it seems to work, so most likely the problem consists in communicating with the wifi module from the second core, but I'm not sure if it's a bug or that's a limitation, I can't seem to find it documented.