UART not working with today's version of micropython

RP2040 based microcontroller boards running MicroPython.
Target audience: MicroPython users with an RP2040 boards.
This does not include conventional Linux-based Raspberry Pi boards.
Tinus
Posts: 40
Joined: Sun Feb 14, 2021 4:53 pm

Re: UART not working with today's version of micropython

Post by Tinus » Tue Apr 27, 2021 11:37 am

I am seeing some delay in the handling of my interrupts when the code is running on one core.
Would it be possible to run my interrupt handler in core 2?

Would that be as simple as running the initialisation on core2 or would I have to have a loop running on core 2 for that to work?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: UART not working with today's version of micropython

Post by Roberthh » Tue Apr 27, 2021 11:50 am

I still have no grip on that topic. The only thing I noticed is, that it runs stable if the interrupt handling is on the first core (core 0). Then the second core may run other tasks.

Tinus
Posts: 40
Joined: Sun Feb 14, 2021 4:53 pm

Re: UART not working with today's version of micropython

Post by Tinus » Tue Apr 27, 2021 11:54 am

And since my sensor and the uarts both use interrupts they should both be on core 0?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: UART not working with today's version of micropython

Post by Roberthh » Tue Apr 27, 2021 12:38 pm

Yes. I would try that.

Tinus
Posts: 40
Joined: Sun Feb 14, 2021 4:53 pm

Re: UART not working with today's version of micropython

Post by Tinus » Tue Apr 27, 2021 7:53 pm

I tried starting my sensor interrupt handler from core_1 but found that the handler then runs on core_0 anyway.

So I guess that if I am running code on core_1 that sends data to the UART buffers the interrupts for those buffers run on core_0. Could that be what is messing up the memory?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: UART not working with today's version of micropython

Post by Roberthh » Tue Apr 27, 2021 8:21 pm

Thank you for raising that question. That brought me to change my test. The problem with duplicate characters being sent disappears if the instantiation of the UART is made in the thread that finally uses the UART. So if you move the UARt set-up to core1 as well, then the problem may be gone.

P.S.: The freezing of the device caused by memory corruption still exists. That's a problem in garbage collect.

Post Reply