Using chain_to to retrigger DMA1 with DMA2 #18193
-
|
DMA1 streams waveform data to a PIO state machine which interfaces to a SPI device. DMA2 is intended to write 1 word to the CH1_AL3_READ_ADDR_TRIGGER so that DMA1 restarts from the beginning of the buffer on every cycle. I don't know how to write the Any suggestions? Many thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
|
I found my own answer. dma1.config(
read=dma1_buffer,
...
dma2.config(
read=id(dma1_buffer),
... |
Beta Was this translation helpful? Give feedback.
-
|
As it turns out, I am still struggling to find a proper solution to chain my DMA channels. I have the following code. ...
DMA_BASE=0x5000_0000
CH0_AL3_READ_ADDR_TRIG=0x3c
CHx_AL3_READ_ADDR_TRIG=[i * 64 + DMA_BASE + CH0_AL3_READ_ADDR_TRIG for i in range(12)]
dma1_ctrl = dma1.pack_ctrl(
enable=True,
high_pri=True,
size=2, # WORD=2, default
inc_read=True,
inc_write=False,
chain_to=dma2.channel,
treq_sel=DREQ_PIO0_TX1,
bswap=False,
)
dma1.config(
read=memoryview(dma1_buffer),
write=spi_sm,
count=len(dma1_buffer),
ctrl=dma1_ctrl,
)
dma2_ctrl = dma2.pack_ctrl(
enable=True,
size=2, # WORD=2, default
inc_read=False,
inc_write=False,
bswap=False,
)
dma2.config(
read=addressof(dma1_buffer),
write=CHx_AL3_READ_ADDR_TRIG[dma1.channel],
count=1,
ctrl=dma2_ctrl,
...The concept is to reload the read trigger register for dma1 to initiate the next transfer. The first dma1 transfer works perfectly but successive transfers never occur. Any ideas on what I'm doing wrong? If I want to use the read trigger register to retrigger dma1, how does Micropython know to write the other registers first and save the read for last? I'm not seeing that in the 1.23.0 source (but I'm not that good at read this codebase). |
Beta Was this translation helpful? Give feedback.
-
|
The dma2.config read the first word in dma1_buffer, not the address of dma1_buffer and write it in a ALT3_READ_ADDR_TRIG. To write the address of dma1_buffer, you need to create a 1-word array. |
Beta Was this translation helpful? Give feedback.
-
|
@pmturlais, thank you! This worked for me. For some reason, both of these have the same effect: |
Beta Was this translation helpful? Give feedback.
The dma2.config read the first word in dma1_buffer, not the address of dma1_buffer and write it in a ALT3_READ_ADDR_TRIG.
To write the address of dma1_buffer, you need to create a 1-word array.