Some general questions about DMA and MicroPython #18028
-
Hello everyone, I am working on a project where I am using SM and DMA and have encountered a few ‘problems’ for which I may need some confirmation or a second opinion: Here is a brief overview so that you know what kind of figures we are dealing with: From the description of the RP2350, I gather that the state machine can process 32 bits per clock cycle. At a frequency of 75 MHz, for example, that would be a total of 75,000,000 x 32 bits, which would be a total of 300,000,000 bytes. That's significantly more than I need. I work at 75 MHz, not to process so much data, but to capture all signal changes and not miss anything. For DMA, I read that 100 MBytes/sec is possible as bandwidth across all channels. Since only one channel is ever active for me, this would be, hopefully correctly converted, 1,000,000 bytes per second. Significantly less than SM could deliver, but significantly more than I deliver._ Since I'm able to output the incoming data into bytearrays, which are a correct reproduction of the input without faults, I assume that I am therefore within the scope of what is possible. But unfortunately, there are a few problems or questions: Question 1:I have to following code:
With this code, DMA often doesn't start, or when it starts, the RP2350 crashes after around 5 seconds and I have to do a hard reset. Just to check I do: and I get Now, if I change the code to this Question 2:When using Statemachine SM and DMA, I had the impression that the processor was not being utilised to full capacity. That is my understanding (SM and DMA run independently and do not require processor power). That is why I thought I could activate both and also run separate code at the same time. This works, but not for very long. After about 20 seconds, it usually starts to crash with various error messages indicating that there is no memory available. However, a check with Question 3:With dma1, I write to buffer1 = bytearray(320) and with dma2 to buffer2 = bytearray(320). This is certainly a beginner's question, but I am undecided and have not found a real answer. dma1 and dma2 each write 100x 32 bytes to the bytearray (thus 100 transfers with size=2). The bytearray is then full and it switches to the next DMA. When dma1 is active again, it writes to the same buffer1 and so on. Question 3.1: Am I correct in thinking that the bytearray is overwritten from the beginning again? That would actually be the behaviour I want and the behavior I think I see. Question 3.2: Greetings and many thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 9 replies
-
I almost forgot. Here the code. And I forgot the say, that with count= I have the same problem. This is just a "test-code" with the most essential functions for testing SM and DMA. My complete code is much more extensive, but since the problem also occurs here, the rest of the code is irrelevant.
|
Beta Was this translation helpful? Give feedback.
-
RP2350. A 400kB (400_000) bytearray.
Not to bad, considering the maximum possible of 600 MB/s |
Beta Was this translation helpful? Give feedback.
Right. After that amount of loops you've managed to successfully overwrite your entire memory.
Hint: Your DMA write address constantly increases without ever being reset to the buffer start (where it belongs)
DMA is a harsh mistress!