2021-02-03 05:28 AM
Hello,
I'm trying to get multi-buffer DMA on ADC working. I modified `HAL_ADC_Start_DMA` function to use `HAL_DMAEx_MultiBufferStart_IT`instead of `HAL_DMA_Start_IT.
But for some reason, M0 Completion Callback is executed multiple times before switching to M1 buffer.
uint32_t bit = READ_BIT(((DMA_Stream_TypeDef *)hadc1.DMA_Handle->Instance)->CR, DMA_SxCR_CT);
printf("BIT: %s\r\n", bit ? "1" : "0");
I have this in IRQ handler (on M0 or M1 conversion complete callback), and for some reason, flow is following:
BIT: 1
BIT: 1
BIT: 1
BIT: 0
BIT: 0
BIT: 1
BIT: 1
BIT: 1
BIT: 0
BIT: 0
BIT: 1
BIT: 1
BIT: 0
As you can see, it doesn't switch CT like it should (M0 M1 M0 M1 M0 etc...) but the buffer is used multiple times before it's switched. Any ideas where can be an issue?
Thanks.
Solved! Go to Solution.
2021-02-03 11:08 AM
Isn't the ISR too long/slow, so that several flips of CT bit happen while it completes? (printf is in the ISR?)
JW
2021-02-03 11:08 AM
Isn't the ISR too long/slow, so that several flips of CT bit happen while it completes? (printf is in the ISR?)
JW
2021-02-04 01:47 AM
Hello,
You was right. I had printf in ISR, + printf was polling based (no DMA), so it gives all sense. And also ADC speed was very high.
Thank you very much for your time.