cancel
Showing results for 
Search instead for 
Did you mean: 

Troubleshooting ADC2 on STM32L412KB

CLang.3
Associate

0693W000005CBx3QAG.pngHi,

I'm using both ADC's on the STM32L412KB, code is generated used the STM32 Cude with Low Level Drivers.

ADC1 works as expected, but ADC2 always reads 0, no matter in which configuration. So I'm assuming it's not a hardware fault, but a configuration issue.

In the basic single conversion mode triggered by software the EOC interrupt of ADC2 is triggered, but the Regular date Register of the ADC2 is always equal to 0.

The STM cube configuartion is attached as well as my personal configuration code:

===============================================

init:

 LL_ADC_EnableIT_OVR(ADC2);

 LL_ADC_EnableIT_EOC(ADC2);

 LL_ADC_StartCalibration(ADC2, LL_ADC_SINGLE_ENDED);

 while(LL_ADC_IsCalibrationOnGoing(ADC2)){}

 LL_ADC_Enable(ADC2);

 while (LL_ADC_IsActiveFlag_ADRDY(ADC2) == 0){}

===============================================

cyclic:

LL_ADC_REG_StartConversion(ADC2);

===============================================

ISR:

void ADC1_2_IRQHandler(void)

{

 /* USER CODE BEGIN ADC1_2_IRQn 0 */

if(LL_ADC_IsActiveFlag_OVR(ADC1) || LL_ADC_IsActiveFlag_OVR(ADC2)){

while(1){

LL_GPIO_TogglePin(GPIOC, LL_GPIO_PIN_6);

LL_mDelay(500);

}

}

else if(LL_ADC_IsActiveFlag_EOC(ADC2)){

LL_ADC_ClearFlag_EOC(ADC2);

adc2Results[0] = LL_ADC_REG_ReadConversionData12(ADC2);

}

 /* USER CODE END ADC1_2_IRQn 0 */

 /* USER CODE BEGIN ADC1_2_IRQn 1 */

 /* USER CODE END ADC1_2_IRQn 1 */

}

Any idea where the configuration is wrong or did anyone experience a similar behaviour ?

Best regards and thanks in advance,

Christoph

0 REPLIES 0