2019-11-15 06:09 AM
When I set a GPIO output level to high in the device configuration tool, it generates an LL_GPIO_SetOutputPin call on top just below the EnableClocks inside the MX_GPIO_Init function. This doesn't work. When I copy this call to the bottom of the generated function it works:
static void MX_GPIO_Init(void)
{
LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
/* GPIO Ports Clock Enable */
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOC);
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOD);
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOB);
/* * * * * * * * The generated calls below do not set the GPIOs * * * * * * * */
/**/
LL_GPIO_SetOutputPin(FW_INT_NRST_GPIO_Port, FW_INT_NRST_Pin);
/**/
LL_GPIO_SetOutputPin(SER_DATA_SEL_GPIO_Port, SER_DATA_SEL_Pin);
/**/
LL_GPIO_ResetOutputPin(MCU_GPIO0_GPIO_Port, MCU_GPIO0_Pin);
/* * * * * * * * The generated calls above do not set the GPIOs * * * * * * * */
/**/
GPIO_InitStruct.Pin = PGOOD_Pin;
GPIO_InitStruct.Mode = LL_GPIO_MODE_FLOATING;
LL_GPIO_Init(PGOOD_GPIO_Port, &GPIO_InitStruct);
/**/
GPIO_InitStruct.Pin = LL_GPIO_PIN_14|LL_GPIO_PIN_15|LL_GPIO_PIN_0|LL_GPIO_PIN_1
|LL_GPIO_PIN_2|LL_GPIO_PIN_3|LL_GPIO_PIN_4|LL_GPIO_PIN_5
|LL_GPIO_PIN_6|LL_GPIO_PIN_7|LL_GPIO_PIN_8|LL_GPIO_PIN_9
|LL_GPIO_PIN_12;
GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
LL_GPIO_Init(GPIOC, &GPIO_InitStruct);
/**/
GPIO_InitStruct.Pin = LL_GPIO_PIN_0|LL_GPIO_PIN_1|LL_GPIO_PIN_2|LL_GPIO_PIN_3
|LL_GPIO_PIN_4|LL_GPIO_PIN_5|LL_GPIO_PIN_7|LL_GPIO_PIN_8
|LL_GPIO_PIN_12;
GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/**/
GPIO_InitStruct.Pin = LL_GPIO_PIN_0|LL_GPIO_PIN_2|LL_GPIO_PIN_10|LL_GPIO_PIN_11
|LL_GPIO_PIN_12|LL_GPIO_PIN_13|LL_GPIO_PIN_14|LL_GPIO_PIN_15
|LL_GPIO_PIN_5|LL_GPIO_PIN_6|LL_GPIO_PIN_7|LL_GPIO_PIN_8;
GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/**/
GPIO_InitStruct.Pin = FW_INT_NRST_Pin|MCU_GPIO0_Pin;
GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/**/
GPIO_InitStruct.Pin = SER_DATA_SEL_Pin;
GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
LL_GPIO_Init(SER_DATA_SEL_GPIO_Port, &GPIO_InitStruct);
/**/
GPIO_InitStruct.Pin = LL_GPIO_PIN_2;
GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
LL_GPIO_Init(GPIOD, &GPIO_InitStruct);
/* * * * * * * * They do work when I copy them here: * * * * * * * */
/**/
LL_GPIO_SetOutputPin(FW_INT_NRST_GPIO_Port, FW_INT_NRST_Pin);
/**/
LL_GPIO_SetOutputPin(SER_DATA_SEL_GPIO_Port, SER_DATA_SEL_Pin);
/**/
LL_GPIO_ResetOutputPin(MCU_GPIO0_GPIO_Port, MCU_GPIO0_Pin);
}
HW is STM32F107RCT. Is this a known issue?
2019-11-16 11:51 PM
Maybe Delay after an RCC peripheral clock enabling erratum, have a look e.g. in https://www.st.com/content/ccc/resource/technical/document/errata_sheet/0a/98/58/84/86/b6/47/a2/DM00037591.pdf/files/DM00037591.pdf/jcr:content/translations/en.DM00037591.pdf . I know it's the 'F40x erratum and not 'F10x, but the latter hasn't been updated for some quite time, and the underlying principle is the same.
JW
2019-11-18 02:49 AM
Thank you for the answer. I tried to insert a delay between enabling the clocks and setting the output pins with LL_mDelay(1000) which of course is way too much. Didn't work. But maybe it can't be tested that way. I currently initially set them in main before the while(1) to not get overwritten by the generator.
2019-11-18 05:57 AM
> I tried to insert a delay between enabling the clocks and setting the output pins with LL_mDelay(1000) which of course is way too much. Didn't work.
Then maybe it's something else.
I don't use Cube and don't use the 'F1 (which are different from other STM32 when it comes to GPIO). So maybe try to have a look inside the functions you are calling, and observe the registers as you step through them.
JW
2019-12-28 05:24 AM
Hi
I had the same problem on F103 and I solved it by setting GPIO Pull-up / Pull-down to Pull-up in CubeMX. I noticed it actually sets ODR instead of PUPDR.
Like waclawek.jan said, I also think it's a register difference.
Sorry for my bad english.