2023-06-28 08:58 AM
Hey guys,
Kinda pulling my hair out as to why the pull up resistor is not kicking in? I am expecting when the MCU boots up to see a nice high signal on PA4, but nothing.
I am not sure what I am doing wrong. if I write a 0x01 into ODR it then pulls up, but I know that is not correct.
GPIO configuration:
LL_AHB4_GRP1_EnableClock(LL_AHB4_GRP1_PERIPH_GPIOA);
LL_GPIO_InitTypeDef GPIO_STD_CFG;
LL_GPIO_StructInit(&GPIO_STD_CFG);
GPIO_STD_CFG.Alternate = 0;
GPIO_STD_CFG.Mode = LL_GPIO_MODE_OUTPUT;
GPIO_STD_CFG.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
GPIO_STD_CFG.Pin = LL_GPIO_PIN_4;
GPIO_STD_CFG.Pull = LL_GPIO_PULL_UP;
GPIO_STD_CFG.Speed = LL_GPIO_SPEED_HIGH;
LL_GPIO_Init(GPIOA, &GPIO_STD_CFG);
GPIOA Reg:
Logic Analazyer
Solved! Go to Solution.
2023-06-28 10:26 AM
If you want it to be high, you can set ODR=1 before you set it to output mode. Pullups/pulldowns do nothing in output push-pull mode except waste power if enabled.
2023-06-28 09:20 AM
GPIO_STD_CFG.Mode = LL_GPIO_MODE_OUTPUT; GPIO_STD_CFG.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
I think there's a misunderstanding on what you think it should do. Why do you think it should be high?
It's configured as a push-pull output, and since ODR=0, it's set to low. If you want it as open-drain or as an input, where the pullup would actually do something useful, do those instead.
2023-06-28 09:36 AM - edited 2023-06-28 09:39 AM
No problem, it could easily be a misunderstanding, The reasoning behind my thinking is simply within the reference manuel pg 537 Figure 73. It states "Push-pull mode: a “0” in the output register activates the N-MOS whereas a “1” in the output register activates the P-MOS" within pg 536 11.3.10 so to me
This simply should set your GPIO high as soon it turns on as the Pull up is enable and the ODR reg is 0 thus activating NMOS that will start sinking the Pull up, is all.
Also. maybe I wasnt clear with my intention but I do want my GPIO to start HIGH as soon as the MCU boots, this pin will be used as a Chip Select for SPI.
2023-06-28 09:55 AM
Edit: Nevermind, I see where I made my mistake. Its actually zero on that node due to the NMOS, I believe this is where I went wrong.
2023-06-28 10:26 AM
If you want it to be high, you can set ODR=1 before you set it to output mode. Pullups/pulldowns do nothing in output push-pull mode except waste power if enabled.