cancel
Showing results for 
Search instead for 
Did you mean: 

DMA's CT register is not changing after conversion

Despair1337
Associate III

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.

1 ACCEPTED SOLUTION

Accepted Solutions

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

JW

View solution in original post

2 REPLIES 2

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

JW

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.