Make good use of the dual cores of the RP2350(PICO2) to assist IRQ #17952
-
Hi there, I'm working on a project which is about receiving data from UART. I use UART triggers to receive data, but it seems like that RP2350 appears to be lagging (REPL responds very slowly to my interrupt commands). Now I'm considering if I can manually set IRQ handlers running on a specific core, in order to reduce the lag(maybe?). I googled, and seems like Pico SDK can disable/enable a core for IRQ. But I cannot find anything tutorials about how to choose a core manually. Is there are something wrong in my idea or I missed something in document? Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
It seems as if the |
Beta Was this translation helpful? Give feedback.
-
What is the response time you notice? |
Beta Was this translation helpful? Give feedback.
-
I apologize, but I may be wrong about the UART IRQ. it may be that I wrote the code in question all the way into main.py (using the timer to poll for data). I guess this causes the REPL to respond slowly. For the response time, it might have been well over 5s (estimated, but pico are slow to respond to Interrput) Here is my code(Simplified & Abridged) // in main.py
def receive_msg():
pass
def msg_queue(t: Timer):
// receive something from another device by UART
if __name == "__main__":
device.uart.irq(msg_queue, UART.RX_IDLE, hard=False)
timer.init(period=1000, mode=Timer.PERIODIC, callback=msg_queue)
while True:
do_something()
// do something else, pretty slow Anyway, thank for the reply! |
Beta Was this translation helpful? Give feedback.
-
It would help us to offer suggestions if you told us more about the data source:
|
Beta Was this translation helpful? Give feedback.
OK, this is quite undemanding.
The easy way to do this is to forget about interrupts and threading. Use
asyncio.StreamReader
, specifically thereadline()
method. See this example: this has a Pyboard concurrently sending and receiving messages. See tutorial and docs for general information aboutasyncio
.There is a bit of a learning curve, but
asyncio
really is the easiest way to interface UARTS and to have other code run concurrently.