2024-05-21 05:14 AM
So the background is essentially this -
I however see some SPI data being missed/skipped right after the first NDTR data.
Things I have tried -
(Figure showing the discontinuity)
My question is essentially whether this is documented behaviour, and if so, whether there's some heuristics available on the time penalty.
Any leads/pointers would be very helpful!
Thanks
2024-05-21 06:00 AM
You have to look at the CT bit in DMA_SxCR to know which of DMA_SxM0AR and DMA_SxM1AR you need to update on each transaction-complete callback.
2024-05-21 06:07 AM - edited 2024-05-21 06:07 AM
Hi @Danish1 , thanks for the reply!
Sorry, should've mentioned I registered a callback using the HAL API, so I'm positive the transfer-complete callback is invoked only when CT=1.
To be doubly sure, I also stored the CR register value inside the callback, first thing, and inspected it later - CT was indeed 1 as expected.
2024-05-21 06:18 AM
You'll have to delve into the HAL source-code as to how they try to make it work. CT might be 1 on the first time the callback happens. But it should toggle each time.
How it _should_ work (without HAL):
I don't use HAL. But I do successfully use double-buffered DMA at 921600 baud on a UART.
2024-05-21 06:42 AM - edited 2024-05-21 06:43 AM
Thanks @Danish1 !
So, you can register two separate callbacks with HAL - one for M0-complete, and the other for M1-complete.
The callback I was referring to, above, is the M0-complete - here I hope to ultimately be able to update the M0AR.
There is a single IRQ line for DMA interrupts, and the HAL decides which callback to invoke after checking the CT value.
My understanding matches the steps you've enumerated.
But given that you were able to use double-buffered DMA with UART at that rate, I guess I could double-check my implementation.
But specifically on the CT bit - had I been updating the M0AR at the wrong CT value, the RM says DMA should've aborted and the stream disabled. That's clearly not what's happening in my case - as I still get proper data after the momentary glitch/discontinuity. Any thoughts on this?