2021-11-04 07:26 PM
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.
Solved! Go to Solution.
2021-11-05 06:20 AM
> (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)
Wouldn't that indicate there is an issue with power somewhere? How is SDA above the 3.3V rail?
How do you know the device connected to PA2 isn't pulling down the line? A ~1kOhm inline resistor would allow you to check that the two aren't both driving.
2021-11-05 06:20 AM
> (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)
Wouldn't that indicate there is an issue with power somewhere? How is SDA above the 3.3V rail?
How do you know the device connected to PA2 isn't pulling down the line? A ~1kOhm inline resistor would allow you to check that the two aren't both driving.
2021-11-05 07:17 PM
>(Wouldn't that indicate there is an issue with power somewhere? How is SDA above the 3.3V rail?)
There are 6 power banks inserted in the cabinet, and the battery voltage range of the power bank is 3.2~4.2V
>(How do you know the device connected to PA2 isn't pulling down the line?)
Sorry, I didn't understand what you mean.
But what is certain is that after a problem occurs, disconnect PA2 from other devices. Like step 2 above, PA2 still cannot send a low level.