2024-06-06 04:41 AM
I'm using the STM32L475 processor with STM32CubeMX 6.11.1.
I have configured ADC1 to read two channels, an external input and the internal temperature - see configuration image in CubeMX. The code to drive the adc reading is simple:
int16_t Channel;
void Adc_Convert(void)
{
Channel = 0;
if (HAL_ADC_Start_IT(&hadc1) != HAL_OK)
{
for(;;) ;
}
}
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef * hadc)
{
Adc.Result[Channel] = HAL_ADC_GetValue(hadc);
Channel++;
}
void HAL_ADC_ErrorCallback(ADC_HandleTypeDef * hadc)
{
uint32_t err = HAL_ADC_GetError(hadc);
}
Adc_Convert() is called once every 2 seconds. I only ever get 1 end-of-conversion interrupt, so the temeprature input is never being read - I can see this both by looking at the Adc.Result array and by using breakpoints to confirm. HAL_ADC_ErrorCallbackI() is never called.
This seems quite a minimal example of trying to use the ADC with interrupts, so what is going on?
All suggestions or help appreciated.
Solved! Go to Solution.
2024-08-06 02:25 AM
Hello,
I would recommend you to refer to the following example with the ADC sequencer implementation. You can find it in the STM32Cube_FW_L4_V1.18.0 repository and folder \Projects\STM32L476G-EVAL\Examples\ADC\ADC_Sequencer.
Let me know if you need further information.
Regards, Simon
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-08-06 02:25 AM
Hello,
I would recommend you to refer to the following example with the ADC sequencer implementation. You can find it in the STM32Cube_FW_L4_V1.18.0 repository and folder \Projects\STM32L476G-EVAL\Examples\ADC\ADC_Sequencer.
Let me know if you need further information.
Regards, Simon
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-08-06 03:43 AM
What's the ADC clock source?
Try lower ADC clock frequency and enable compiler optimizations.
JW