The MCU usart Tx pin can't output high level occasionally
Hi,Master:
platform: STM32G030C8T6
Block diagram: As shown in the following diagram, STM32G030C8 as a battery cabinet communicates with 6 power banks through SDA_X. In addition, USART2 (Tx/Rx)
communicates with the host, and USART1 (Tx_1/Rx_1) communicates with other slaves.
problem:
There is no abnormality in the program, and the USART2 Tx pin of some cabinets cannot send high level in batch products.
analyze:
1. Disconnect the connection with the host and other slaves, the USART2 Tx pin cannot send high level
2. Under keil, the jlink online monitoring program, reset the program (the kernel and peripherals are reset), the program runs the following code in a single step:
int main(void)
{
__HAL_RCC_GPIOA_CLK_ENABLE();
GPIO_InitTypeDef GPIO_InitStruct = {0};
GPIO_InitStruct.Pin = GPIO_PIN_2 | GPIO_PIN_5;
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);
while (1)
{
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_2, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_2, GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET);
}
}
PA5 can output high and low levels, PA2 cannot output high levels
3. Power off the machine, perform 2 steps, the result is the same as 2. (The power bank voltage will flow back to V3.3, there is about 1.4V on V3.3, and SDA_X has a little more than 2V)
4. Disconnect the power bank from the machine, restart the machine after power off, execute 2, then PA2 can output high and low levels normally
Additional questions:
As in step 2 above, why the USART2 Tx pin still cannot be restored to normal after resetting?
Thank you very much.
