cancel
Showing results for 
Search instead for 
Did you mean: 

L432 GPIO registers unexpected reset value and GPIOs not functioning

ZJing
Associate III

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

 

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

5 REPLIES 5
TDK
Guru

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".
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

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

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

You're right. Thank you very much!