AnsweredAssumed Answered

STM32F3 ADC Bug in Interrupt Enable of HAL

Question asked by artes.benjamin on Jun 20, 2017
Latest reply on Jun 20, 2017 by artes.benjamin

I've been working on a board based on the STM32F3 with a large number of ADCs and other peripherals.  I'll also be using multiple I2C and UART peripherals; the responsiveness of I2C and UART is much higher than the ADCs so I have to reserve DMA usage for I2C and UART.

 

Due to the above restriction, I planned to use the Single ADC Conversion interrupt to manually store the results of conversions.  After implementing this I ran into an issue caused by HAL not respecting by choice of End of Conversion Selection:

 

In my Initialization code, all four ADCs were configured with 

handle.Init.EOCSelection          = ADC_EOC_SINGLE_CONV;

 

After running into issues I traced the source of the problem back to lines ~2074 of stm32f3xx_hal_adc_ex.c:

 

They Are:

      /* Enable ADC end of conversion interrupt */
      /* Enable ADC overrun interrupt */ 
      switch(hadc->Init.EOCSelection)
      {
        case ADC_EOC_SEQ_CONV:
          __HAL_ADC_DISABLE_IT(hadc, ADC_IT_EOC);
          __HAL_ADC_ENABLE_IT(hadc, (ADC_IT_EOS));
          break;
        /* case ADC_EOC_SINGLE_CONV */
        default:
          __HAL_ADC_ENABLE_IT(hadc, (ADC_IT_EOC | ADC_IT_EOS));
          break;
      }

They Should be:

      /* Enable ADC end of conversion interrupt */
      /* Enable ADC overrun interrupt */ 
      switch(hadc->Init.EOCSelection)
      {
        case ADC_EOC_SEQ_CONV:
          __HAL_ADC_DISABLE_IT(hadc, ADC_IT_EOC);
          __HAL_ADC_ENABLE_IT(hadc, (ADC_IT_EOS));
          break;
        /* case ADC_EOC_SINGLE_CONV */
        case ADC_EOC_SINGLE_CONV:
            __HAL_ADC_DISABLE_IT(hadc, ADC_IT_EOS);
            __HAL_ADC_ENABLE_IT(hadc, (ADC_IT_EOC));
            break;
        /* case ADC_EOC_SINGLE_SEC_CONV */
        default:
          __HAL_ADC_ENABLE_IT(hadc, (ADC_IT_EOC | ADC_IT_EOS));
          break;
      }

 

 

I know I'm not using the latest version of the F3 libraries (haven't had a chance to update yet), but I checked V1.8 and the issue is still present.

Outcomes