cancel
Showing results for 
Search instead for 
Did you mean: 

My adc on a STM32F091RC does not work anymore after CubeMX upgrade

Posted on January 29, 2018 at 09:30

Hi. I have a very strange behaviour with adc.

The CubeMX setup is shown below0690X00000609VvQAI.png0690X00000609WjQAI.png

This is my empty callback

void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc) {

}

And the main

int main(void)

{

  HAL_Init();

  SystemClock_Config();

  MX_GPIO_Init();

  MX_ADC_Init();

  HAL_ADC_Start_IT(&hadc);

  while (1)

  {

    HAL_GPIO_WritePin(Led0_GPIO_Port, Led0_Pin, GPIO_PIN_SET);

    HAL_Delay(100);

    HAL_GPIO_WritePin(Led0_GPIO_Port, Led0_Pin, GPIO_PIN_RESET);

    HAL_Delay(100);

  }

}

The program does not work. In order to have my led blinking it working I have to comment out the line

HAL_ADC_Start_IT(&hadc);

What is wrong?

3 REPLIES 3
T J
Lead
Posted on January 29, 2018 at 10:34

on my '091 solution I am using cube 4.22.1, not using the A/D/Interrupt, but DMA,

I use this:

#define ADC_ChannelCount; 12;

void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc) {

    if(!ADC_ChannelsCounter--) {      // after all the channels have been refilled

        ADC_ChannelsCounter = ADC_ChannelCount;

        HAL_ADC_CompleteCycle = true;         // signal foreground to process

        // copy 15 results away now

               ADC_Channel_Buffer[i] = ADC_DMABuffer[i];

    }

}
Posted on January 29, 2018 at 11:42

Many thanks for your fast reply.

Now I have switched my project to dma but I have a problem.

hadc.Init.ContinuousConvMode = ENABLE;

seems to be not considered because the variable will updated only one time.