Skip to main content
ZJing
Associate III
August 14, 2023
Solved

L432 GPIO registers unexpected reset value and GPIOs not functioning

  • August 14, 2023
  • 5 replies
  • 2218 views

Hi all,

I am trying to toggle a IO pin but the pin just will not turn on.

I checked register values at startup before main(), and some of the values are the the same as the reset values shown in the reference manual:

ZJing_0-1692020321077.png

Every register has been set to the reset value of MODER of the corresponding GPIO port, but not the register's own reset value.

I initialized the IO pins and ports, and set them, but the voltage on the pin would still be GND

 

 LL_GPIO_ResetOutputPin(TIN_PORT, TIN_PIN);

 LL_GPIO_ResetOutputPin(TOUT_PORT, TOUT_PIN);
/* GPIO Ports Clock Enable */
	LL_APB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA);
	LL_APB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB);
	LL_APB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC);

	LL_GPIO_InitTypeDef GPIO_InitStruct = {0};

	GPIO_InitStruct.Pin = ADIN_PIN|(ADIN_PIN << 1);
	GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
	GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
	LL_GPIO_Init(ADIN_PORT, &GPIO_InitStruct);

	/*TRIP GPIO Configuration
	PB8 ------> TRIP
	*/

	GPIO_InitStruct.Pin = TRIP_PIN;
	GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
	GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
	GPIO_InitStruct.Pull = LL_GPIO_PULL_DOWN;
	LL_GPIO_Init(TRIP_PORT, &GPIO_InitStruct);

	GPIO_InitStruct.Pin = TOUT_PIN;
	GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
	GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
	GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
	LL_GPIO_Init(TOUT_PORT, &GPIO_InitStruct);

 

What is happening and is there a way to fix it?

 

Thanks in advance,

Zhi

 

This topic has been closed for replies.
Best answer by waclawek.jan

If you observe this behaviour for GPIO, read out and check also the respective RCC clock enable register.

If you'd do that, you'd realize what's the error:

> LL_APB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA);

JW

5 replies

TDK
August 14, 2023

Seems like a debugger issue. Look at the settings immediately after enabling the clocks. If they're correct, step through to see where they get changed.

"If you feel a post has answered your question, please click ""Accept as Solution""."
waclawek.jan
Super User
August 15, 2023
Every register has been set to the reset value of MODER of the corresponding GPIO port, but not the register's own reset value.

This is how GPIO behave before you enable their clocks.

Read out and check/post content of GPIO registers after you've set them up.

JW

ZJing
ZJingAuthor
Associate III
August 16, 2023

Hi,

I did enable the clocks in the GPIO init function:

	LL_APB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA);
	LL_APB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB);
	LL_APB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC);
waclawek.jan
waclawek.janBest answer
Super User
August 16, 2023

If you observe this behaviour for GPIO, read out and check also the respective RCC clock enable register.

If you'd do that, you'd realize what's the error:

> LL_APB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA);

JW

ZJing
ZJingAuthor
Associate III
August 16, 2023

You're right. Thank you very much!