STM32CubeMX incorrect code generation for EXTI on STM32H7 with LL driver
I am using STM32CubeMX 6.2.1 with STM32H7 package 1.9.0.
Some IOs are configured as EXTI, and I have configured CubeMX to use LL for GPIO.
The generated code per IO is:
LL_SYSCFG_SetEXTISource(LL_SYSCFG_EXTI_PORTG, LL_SYSCFG_EXTI_LINE12);
/**/
EXTI_InitStruct.Line_0_31 = LL_EXTI_LINE_12;
EXTI_InitStruct.Line_32_63 = LL_EXTI_LINE_NONE;
EXTI_InitStruct.Line_64_95 = LL_EXTI_LINE_NONE;
EXTI_InitStruct.LineCommand = ENABLE;
EXTI_InitStruct.Mode = LL_EXTI_MODE_IT;
EXTI_InitStruct.Trigger = LL_EXTI_TRIGGER_RISING_FALLING;
LL_EXTI_Init(&EXTI_InitStruct);
/**/
LL_GPIO_SetPinPull(...);
Note that there is no LL_GPIO_Init() call, as would be the case with non-EXTI GPIOs.
Because that call is missing, the GPIOx_MODER setting is remaining at the default, which for H7 appears to be 0b11 (analog). This appears to be a mistake in the reference manual also, which lists 0b00 as the default.
With the default (analog) setting, the external input is never sensed.
Calling LL_GPIO_SetPinMode() explicitly (in my user code) works.
But I think the "proper" fix is for CubeMX autogen to also call LL_GPIO_Init() on EXTI pins?
With the HAL GPIO driver, the configuration is correct.