2024-05-08 04:33 AM
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
2024-05-08 04:50 AM - edited 2024-05-08 04:51 AM
Have you set sequence count to 2 in the ADC initialisation (not the DMA)?
2024-05-16 07:10 AM
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.
2024-05-31 07:07 AM
Have you tried searching for a "count" at all? Seems like DMA/ADC is set up for 2 conversions, but you expect 4.
2024-06-04 05:52 AM - edited 2024-06-04 05:53 AM
Hey Tobe,
No in this case I don't read with DMA, I poll the 4 channels manually.
I forgot to mention, that the readout with DMA was successful.
But I found a mistake in the code in the meantime here
while( (this->adcReg->ISR & ADC_ISR_EOC) != 1 );
This must be correctly
while( !(this->adcReg->ISR & ADC_ISR_EOC) );