cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G051F8P6 GPIO state during reset

troper
Associate

Hello,

I have some strange behavior with a circuit.  My understanding is that the GPIO should be configured as an input at power up, however, I am seeing a brief flash on an LED during power up and Power down (images attached showing circuit and the 3.3 as well as LED_R signals).  In firmware, I am doing the following in the MX_GPIO_Init() routine:

/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();

/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(CS_PWR_GPIO_Port, CS_PWR_Pin, GPIO_PIN_SET);

/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOA, FBK_Pin|TP_1_Pin, GPIO_PIN_RESET);

/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOA, LED_B_Pin|LED_G_Pin|LED_R_Pin, GPIO_PIN_SET);

/*Configure GPIO pins : PB8 PB9 PB0 PB1
PB2 PB3 PB4 PB5 */
GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_0|GPIO_PIN_1
|GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

/*Configure GPIO pin : CS_PWR_Pin */
GPIO_InitStruct.Pin = CS_PWR_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(CS_PWR_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pin : PC15 */
GPIO_InitStruct.Pin = GPIO_PIN_15;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

/*Configure GPIO pin : FBK_Pin */
GPIO_InitStruct.Pin = FBK_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
HAL_GPIO_Init(FBK_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pin : TEACH_Pin */
GPIO_InitStruct.Pin = TEACH_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(TEACH_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pins : TP_1_Pin LED_B_Pin LED_G_Pin LED_R_Pin */
GPIO_InitStruct.Pin = TP_1_Pin|LED_B_Pin|LED_G_Pin|LED_R_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

So it is being SET before initializing the port.

Am I missing something as to why this LED is giving a brief pulse on power up or power down (as if the pin is allowing to sink a bit of current briefly until the rail goes away).

Thank you in advance

0 REPLIES 0