Skip to main content
Graduate
May 8, 2024
Question

ADC polling of multiple channels

  • May 8, 2024
  • 1 reply
  • 1462 views

Hello,
After setting up a 4 channel read with DMA, I ran into the problem, that the value of the internal temperature sensor seemed to not change at all. The values of the read out potentiometer however were plausible.
So I wanted to check all used channels by manually polling them.
But in this case it seems that the EOS flag is set before the loop finishes reading the data, though I have the WAIT bit set in CFGR1.

 if( (this->adcReg->ISR & ADC_ISR_ADRDY) != 0 )
 this->adcReg->CR |= ADC_CR_ADSTART;

 for( uint8_t index = 0; index < this->numOfChannels; index++){
 while( (this->adcReg->ISR & ADC_ISR_EOC) != 1 );
 this->adcData[index] = this->adcReg->DR;
 }

 So here my debugger runs to infinity stuck in the while loop with index = 2 and adcData[0] and [1] having data.

Do you have ideas why this isn't working? I also read in the forum, that multichannel data handling is not recommended for polling, but it must work according to how I understood the timing diagrams in the reference manual.

Thanks for your help in advance.
Hannes

    This topic has been closed for replies.

    1 reply

    Graduate
    May 8, 2024

    Have you set sequence count to 2 in the ADC initialisation (not the DMA)?

    Graduate
    May 16, 2024

    Hi Tobe,
    What do you mean with sequence count? Is it inside a register? Because I didn't find anything in the respective register section of the ref manual.

    Graduate
    May 31, 2024

    Have you tried searching for a "count" at all? Seems like DMA/ADC is set up for 2 conversions, but you expect 4.