Skip to main content
Nabekaite
Associate II
June 17, 2021
Question

STM32G473 can't start debugging with incoming data stream on USART1 Rx pin

  • June 17, 2021
  • 28 replies
  • 8972 views

On my board i use USART1 and USART3 to connect my device to other by dual RS-485. 485 tranciever connected to MCU throw digital isolator (4 tx, 2 rx SI8662). If 485 line of USART1 not connected ti device i can start debugging in Keil without problem. If i connect 485 line debug session immediately fail. If i connect line before debuging then i can't enter debug. Even ST-Link Utility can't connet to MCU with connected 485 line. I can load programm to MCU, connect 485 line an device will work fine by self. With 485 of USART3 no eny problem.

There is no galvanic connection between MCU and 485 tranciever, no ground connected. Power of both part of device is fine, no any noise.

Boot0 on MCU connected to GND. I use ST-Link v2 and SWD-connection.

Why debugging not work with incoming data stream on USART1?0693W00000BbGiqQAF.png

This topic has been closed for replies.

28 replies

Nabekaite
NabekaiteAuthor
Associate II
June 18, 2021

New information: logic analyzer connectet to SWD, USART Rx, nRST and NJTRST pins show me some interesting. I have short pulses on nRST pin of MCU. To this pin connected only pullup resistor 100k to 3.3 V.

If i connect to MCU by ST-Link Utility this pulses is gone. But when try to load FW from Keil pulses not gone and load fails. 0693W00000BbN4nQAF.pngPulse period 515 ms, duration ~31 uS.

Why this pulses is generating, how it turn off and how to upload FW from Keil?

waclawek.jan
Super User
June 18, 2021

NRST is a bidirectional pin, if the debugger decides to perform a software reset, you'll see a pulse on it.

JW

Nabekaite
NabekaiteAuthor
Associate II
June 19, 2021

Look at the right part of diagram - there are pulses even without data on the SWD. This is not a debugger job. There is no NRST conneted to debugger, only SWCLK and SWDIO.

waclawek.jan
Super User
June 19, 2021

Maybe watchdog? Do you employ watchdog in your program, or do you have WWDG_SW active (i.e. 0) in option bytes?

Rx is PA10? What happens if you pull NJTRST pin up hard enough to overcome the CC Rd pulldown, e.g. using a 1kOhm pullup?

JW

Nabekaite
NabekaiteAuthor
Associate II
June 19, 2021

"Do you employ watchdog in your program" - FLASH erased

"WWDG_SW active (i.e. 0) in option bytes" - to the best of my memory WWDG_SW set to 1 (factory value).

"Rx is PA10" - Yes.

"What happens..." - try this in moday. Device at work.

I had a stupid idea that these pulses are created by the MCU itself, reading all the empty memory sequentially. FF in memory, perceiving as a command NOP. After the end of memory, reset and everything from the beginning.

waclawek.jan
Super User
June 19, 2021

Empty FLASH should end up in bootloader, see AN2606.

JW

TDK
June 19, 2021

The pulses on JRST are correlated with RX. Probably just noise being transferred. An analog capture would likely confirm.

> I have short pulses on nRST pin of MCU. To this pin connected only pullup resistor 100k to 3.3 V.

You should have a 0.1uF cap on NRST to avoid parasitic resets. Probably not the issue, but could be.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Nabekaite
NabekaiteAuthor
Associate II
June 21, 2021

"An analog capture would likely confirm." -

0693W00000BbUynQAF.png0693W00000BbUzqQAF.png 

Unsolder relay circuit (R43), add 1k pull up to JRST + 1.0 uF to nRST. Try 0.1 uF but only nRST pulse width change.

0693W00000BbV26QAF.png 

RST impulses are still in place but wider)

Code downloading and debugging from Keil not possible.

waclawek.jan
Super User
June 21, 2021

At this point, I'm out of ideas.

If connection with STLink-Utility works, and with Keil doesn't, then this may be some Keil-specific issue.

JW

Nabekaite
NabekaiteAuthor
Associate II
June 21, 2021

With STLink-Utility not all is ideal. 

When i try download FW from Keil end got error, then i checked FLASH by STLink-Utility and see that some FLASH was flashed. After that i can't erase chip because " Error occured during flash mass erase!"