2023-02-09 03:26 AM
Hi I am trying to implement a simple ADC conversion, 1 channel, discontinuous, using STM32F070F6. The code is generated by CubeMX using STM32Cube FW 1.11.3.
Direct Conversion
The direct conversion works.
HAL_ADC_Start(&hadc);
HAL_ADC_PollForConversion(&hadc, HAL_MAX_DELAY);
m_ui32ADC_raw = HAL_ADC_GetValue(&hadc);
Interrupt (HAL_ADC_Start_IT)
I call
HAL_ADC_Start_IT(&hadc);
but HAL_ADC_ConvCpltCallback() never fires. I noticed that the ADC1_IRQHandler defined in the startup file is not implemeted in the code. I try to add this function and call HAL_ADC_ConvCpltCallback inside but the ADC1_IRQHandler is not called.
DMA conversion
With DMA I get an hardFault from HAL_ADC_Start_DMA, precisely in the assignment
hadc->DMA_Handle->XferCpltCallback = ADC_DMAConvCplt;
If I will be able to implement the interrupt conversion I will be happy. Thank you for the support.
2023-02-09 03:47 AM
> I noticed that the ADC1_IRQHandler defined in the startup file is not implemeted in the code.
Enable that interrupt in the Chip Configruration (.ioc) Tool on the ADC NVIC Interrupt tab.
For the DMA: Have you enabled DMA in the Chip Configruration (.ioc) Tool?
hth
KnarfB
2023-02-09 04:46 AM
Thank oyu KnarfB,
I have enabled ADC NVIC and also DMA.
A bug of the CubeMX? I have used ADC conversion several times on STM32F7 and I had not these troubles.
2023-02-09 06:28 AM
Solved. CubeMx was generating on a different directory :-(. Now everything is working as expected.