Skip to main content
Denis Gottardello
Associate III
January 29, 2018
Question

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

  • January 29, 2018
  • 3 replies
  • 662 views
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?

    This topic has been closed for replies.

    3 replies

    T J
    Senior III
    January 29, 2018
    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];

        }

    }
    Denis Gottardello
    Associate III
    January 29, 2018
    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.
    T J
    Senior III
    January 30, 2018