Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADC External Trigger Conversion Sources Incorrect for Category 1 Devices #7

Open
mbrossett opened this issue Aug 11, 2023 · 2 comments
Assignees
Labels
hal HAL-LL driver-related issue or pull-request.

Comments

@mbrossett
Copy link

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);
}

RefManual_ADC_ExtTrigConv_Sources

RefManual_Device_Categories

ST32CubeMX_ADC_Config

ST32CubeMX_TIM21_Config

stm32l0xx_hal_adc_ex_BUG

@RJMSTM RJMSTM self-assigned this Aug 15, 2023
@RJMSTM RJMSTM added the hal HAL-LL driver-related issue or pull-request. label Aug 15, 2023
@RJMSTM
Copy link
Contributor

RJMSTM commented Aug 15, 2023

Hello @mbrossett ,

Thank you for this report. We will get back to you as soon as we analyze it further. This may take some time. Thank you for your comprehension.

With regards,
Rania

@mbrossett
Copy link
Author

Thank you @RJMSTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hal HAL-LL driver-related issue or pull-request.
Projects
None yet
Development

No branches or pull requests

2 participants