cancel
Showing results for 
Search instead for 
Did you mean: 

Injected ADC conversion on STM32F303 not work correctly

MarcoF
Associate

Hello,

in my project I have to acquire 2 channels in injected mode and 7 channels in regular mode on ADC1. The first injected channel is not converted correctly, sometimes it seems to be blocked for several samples and then it starts working again. If I invert the conversion sequence of the two injected channels the problem remains on the first converted channel. The problem remains even if I block the conversion of regular channels.

Any suggestions?

3 REPLIES 3
Ozone
Lead

Probably a code issue. How do you retrieve the results ?

The injection mode has EOC (for each channel) and EOS (for the sequence) as well, and a single result register.

And the ref manual says:

Note: It is not possible to use both the auto-injected and discontinuous modes simultaneously.

MarcoF
Associate

Hi Ozone,

I read data into ADC1 interrupt routine ad the end of sequence.

Discontinuos mode is disable in CubeMx, I use 4.20 version for compatibility with previous versions, not the last version.

The code in project is:

/* activate interrupt */

 LL_ADC_WriteReg(ADC1, IER, LL_ADC_IT_JEOS);

/* ADC1 interrupt routine */

void ADC1_2_IRQHandler(void)

{

  /* USER CODE BEGIN ADC1_2_IRQn 0 */

   if(READ_BIT(ADC1->ISR, ADC_ISR_JEOS))

   {

      LL_ADC_WriteReg(ADC1, ISR, ADC_ISR_JEOS);

      Adc1IrqCounter++;

      Adc1JData[0] = LL_ADC_ReadReg(ADC1, JDR1);

      Adc1JData[1] = LL_ADC_ReadReg(ADC1, JDR2);

}

....

}

I never used injected mode, surprised to realise there are 4 dedicated result registers ... :o

Have you tried to check for EOC in the interrupt handler, and see if the conversion results are plausible ?

The F30x is not new, but I would nonetheless verify that the actual ADC configuration (config register settings) matches the supposed one. Cube is rumored to contain some bugs...