PIO/SM and DMA crash when writing to file #18140
-
Hello everyone I have here micropython-code, where I have a statemachine and two dma chained to each other writing to a bytearray. Now, the statemachine has a program collecting 15'360 bits, that get written to a bytearray by dma0. dma1 then retriggers dma0 with resetting the writeadress. These work without any problems, and I can check at regular intervals using print() that the state machine and DMA are active. When I print the byte array, I can also see that the values are being updated. Everything works, and I'm happy. However: when I attempt to write the contents of the byte array to a file, the file is created and the byte array is written to the file. But with a timer after 5 seconds, the next file should be written. However, this does not occur. When I check the state machine and DMA again using print() after creating the file, I observe that they are no longer active. So they are both deactivated or crash after or during creation of file. But the RP2350 itself does not crash or freez and the rest of the code, which can be executed without sm/dma is still being executed. The error occurs regardless of whether I save the file to the flash memory or to the SD card. Has anyone else noticed this behavior or has an idea, what could be the cause? Software or hardware? Greetings |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
The RP2040 board runs on a default 125MHz clock while the RP2350 runs 150MHz. |
Beta Was this translation helpful? Give feedback.
Oh, damn it. You can waste hours and days troubleshooting, and then suddenly find the error in just a few attempts. The error was as follows. When reconfiguring DMA0 via DMA1, I determined the address as follows:
self.input_buffer_addr = uctypes.addressof(array.array('L',[uctypes.addressof(self.input_buffer)]))
However, it should be correct as follows:
self.input_buffer_addr = array.array('L',[uctypes.addressof(self.input_buffer)])
This ‘minor’ error caused the crashes. The code has now been running for around 30 minutes and has already written over 360 files without any errors or crashes.
And what have I learned from this? Don't just copy examples that work for other people. Why the inco…