Open scarletwiz opened 7 months ago
With the wiznet driver, SPI transactions are done within critical sections. On the microbit, the CODAL handles SPI transfers and probably uses interrupts (and DMA) to perform this transfer. With MICROPY_BEGIN_ATOMIC_SECTION
the interrupts are disabled and that probably breaks SPI.
You'll need to implement the atomic section in a different way. I'm not sure exactly why the wiznet driver needs atomicity. It may be enough to just implement them as a no-op.
I am currently working on integrating the network functionality into an existing MicroPython module, specifically for WIZNET5K.
I've successfully implemented most features by porating SPI and the
micropython-microbit-v2\lib\micropython\extmod\network_wiznet5k.c
file. However, I encounter a problem where the process freezes at the point in the code whereMICROPY_BEGIN_ATOMIC_SECTION();
is called.Here's the relevant code snippet (micropython-microbit-v2\lib\micropython\extmod\network_wiznet5k.c/ Line 130):
If I omit this section, the process runs, but the mutex functionality, which is crucial for this program, is lost.
This feature operates flawlessly on other MCUs, such as the rp2040 and stm32. What might be causing the difference with the microbit? Or is there another aspect of the modification that I might have overlooked?