cancel
Showing results for 
Search instead for 
Did you mean: 

STMG07 Uart Config after exit System Bootload

TesterSAM
Associate II

Hi,

I have an issue with the UASRT communication being abnormal.

First case:

  1. Access System Bootload Mode by Options bytes
  2. Access the Main Application by the UART protocol ( UART2)
  3. Send the first UART packet to the ST MCU via UART2 that contains the UART error code: 0x4 (Frame Error)
  4. Send the same UART packet to the ST MCU via UART2 again without the UART error code

Second case:

  1. Using IDE Debug Mode, break at main()
  2. Send a UART packet to the ST MCU via UART2 without the UART error code

I tried to De-Init and Re-Init the UART2, which I expect to reset all the UART2 register values before I send the UART packet.

 

According to my test case, could I say that the UART error code 0x4 is due to System Bootload Mode?

How could I fix the issue?

Please let me know if more information is required.

4 REPLIES 4
Saket_Om
ST Employee

Hello @TesterSAM 

Please describe your issue with more details. What is the issue exactly? 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om
TesterSAM
Associate II

I did not expect to get any error code in the UART register when I tried to send the UART Packet to the ST MCU via UART2 after exiting System Bootload Mode (using UART2 to exit the System Bootload mode and access the main application).

 

Although the second packet contains no error, I would like to know the root cause that led to the UART error code:0x4

 

In the ST MCU application, I expected to send a UART packet to execute the ST MCU function.

If the first packet is always ignored due to a Frame Error, the other MCU timing that sends the UART packet would be influenced.

Guenael Cadier
ST Employee

Hi @TesterSAM 
2 things tou could check/try:

1) If the Frame Error bit is set in the ISR of the UART instance you are using after your Init, you could try to clear it by calling 

  __HAL_UART_CLEAR_FLAG(huart2, UART_CLEAR_FEF);

before your reception on embedded side

2) you mention you perform a DeInit/Init procedure of UART before starting the reception. It is expected that the HAL_UART_DeInit() call, executes the HAL_UART_MspDeInit() function.
Please check that you have those 2 macros executed in HAL_UART_MspDeInit() for UART2 case.

  __HAL_RCC_USART2_FORCE_RESET();
  __HAL_RCC_USART2_RELEASE_RESET();

This should reset the flag in ISR.
Regards

TDK
Super User

Look at the signal on the line with a logic analyzer to figure out what's going on. Is TX pulled up with a pullup resistor? FE indicates the line is not stable, probably dipping when the pins get (re)initialized.

If you feel a post has answered your question, please click "Accept as Solution".