Skip to main content
Despair1337
Associate III
Feb 3, 2021 1:28 PM UTC
Solved

DMA's CT register is not changing after conversion

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.

This topic has been closed for replies.
waclawek.jan
waclawek.janBest answer
Super User
Feb 3, 2021 7:08 PM UTC

Isn't the ISR too long/slow, so that several flips of CT bit happen while it completes? (printf is in the ISR?)

JW

2 replies

waclawek.jan
waclawek.janBest answer
Super User
Feb 3, 2021 7:08 PM UTC

Isn't the ISR too long/slow, so that several flips of CT bit happen while it completes? (printf is in the ISR?)

JW

Despair1337
Associate III
Feb 4, 2021 9:47 AM UTC

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.