2017-06-19 03:07 PM
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.
Solved! Go to Solution.
2017-06-20 06:48 AM
Hi
Artes.Benjamin
,ADC_EOC_SINGLE_SEQ_CONV is not used in HAL driver. It is commented as reserved for future usebutit will be removed
in the next release of CubeF3.
#define ADC_EOC_SINGLE_SEQ_CONV ((uint32_t)(ADC_ISR_EOC | ADC_ISR_EOS)) /*!< reserved for future use */
Regards
Imen
2017-06-20 06:48 AM
Hi
Artes.Benjamin
,ADC_EOC_SINGLE_SEQ_CONV is not used in HAL driver. It is commented as reserved for future usebutit will be removed
in the next release of CubeF3.
#define ADC_EOC_SINGLE_SEQ_CONV ((uint32_t)(ADC_ISR_EOC | ADC_ISR_EOS)) /*!< reserved for future use */
Regards
Imen
2017-06-20 03:12 PM
Marked as correct.
I saw that note, but is there a reason that:
It seems like a useful setting to have that is supported by the hardware; why is the HAL removing it? Removing it will likely result in users just manually setting EOC in the IER which, depending on HAL's implementation, could expose them up to MORE bugs (as the HAL code seems to be written with the assumption that the User isn't changing settings in the peripheral outside of HAL calls.)