You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using custom board with STM32L011F3P3.
IDE is Keil MDK Version 5.38 with ST32CubeMX version 6.9.1.
The STM32L0xx reference manual (Feb 2022) states on page 281, that the TIM21_TRGO trigger is only available on Category 1 devices, which is defined on page 47 as the STM32L011x and STM32L021x devices.
CubeMX does not allow setting the ADC external trigger conversion source as TIM21_TRGO. Upon inspection of the HAL driver (stm32l0xx_hal_adc_ex.h, line 68) it is coded to only allow TIM21_TRGO on Cat. 2, 3, and 5 devices (all except Cat. 1).
To determine if the reference manual or the HAL driver was wrong, I manually set the external trigger to TIM21_TRGO (hadc.Init.ExternalTrigConv = ADC_CFGR1_EXTSEL_2;) per ref. manual page 281. Debugging the code I verified the callback, HAL_ADC_ConvCpltCallback(), was being fired and the debug output pin was being toggled in the center of each pulse width of the PWM output as expected. See code snippets below. Screenshots of CubeMX config, HAL driver, ref. manual are attached for reference.
// top of main.c...
HAL_TIM_Base_Start_IT(&htim21);
HAL_TIM_PWM_Start_IT(&htim21, TIM_CHANNEL_1);
HAL_ADC_Start_IT(&hadc);
Using custom board with STM32L011F3P3.
IDE is Keil MDK Version 5.38 with ST32CubeMX version 6.9.1.
The STM32L0xx reference manual (Feb 2022) states on page 281, that the TIM21_TRGO trigger is only available on Category 1 devices, which is defined on page 47 as the STM32L011x and STM32L021x devices.
CubeMX does not allow setting the ADC external trigger conversion source as TIM21_TRGO. Upon inspection of the HAL driver (stm32l0xx_hal_adc_ex.h, line 68) it is coded to only allow TIM21_TRGO on Cat. 2, 3, and 5 devices (all except Cat. 1).
To determine if the reference manual or the HAL driver was wrong, I manually set the external trigger to TIM21_TRGO (hadc.Init.ExternalTrigConv = ADC_CFGR1_EXTSEL_2;) per ref. manual page 281. Debugging the code I verified the callback, HAL_ADC_ConvCpltCallback(), was being fired and the debug output pin was being toggled in the center of each pulse width of the PWM output as expected. See code snippets below. Screenshots of CubeMX config, HAL driver, ref. manual are attached for reference.
// top of main.c...
HAL_TIM_Base_Start_IT(&htim21);
HAL_TIM_PWM_Start_IT(&htim21, TIM_CHANNEL_1);
HAL_ADC_Start_IT(&hadc);
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc)
{
adcVal = HAL_ADC_GetValue(hadc);
HAL_GPIO_TogglePin(DEBUG_OUT_GPIO_Port, DEBUG_OUT_Pin);
}
The text was updated successfully, but these errors were encountered: