cancel
Showing results for 
Search instead for 
Did you mean: 

ADC conversion on STM32F070F6 Direct ADC conversion work but Interrupt and DMA doesn't.

MRaff.1
Associate III

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.

3 REPLIES 3
KnarfB
Principal III

> 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

MRaff.1
Associate III

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.

0693W00000YAMf2QAH.jpg0693W00000YAMexQAH.jpg0693W00000YAMenQAH.jpg

MRaff.1
Associate III

Solved. CubeMx was generating on a different directory :-(. Now everything is working as expected.