cancel
Showing results for 
Search instead for 
Did you mean: 

Why would a project using Uart only work while connecting the USB (StLink) cable to a particular computer?

GGree.1
Associate III

The project uses a Nucleo board with a STM32H723NG on it. I have adapted the NX_TCP_Server project and I am using Usart2 as a port to send and get data from a device that is then transferred over TCP. This all works fine when connected to the desktop (Linux) I originally built the code on. But then I transferred the project over to a laptop running windows and now the UART only sends (tx) zeros. I also transferred the project over to another laptop running Linux and the Uart does the same thing. I also reran the board from the original computer on debug OK, and terminated the debug mode, and ran again while the powered by the USB by hitting reset. That works as well. I am able to spy on the Uart and see all the correct data. Another test I tried was to connect the USB (stLink) cable to a generic USB adapter (2.5A capable) and I get the zeros again.

So the bottom line is I only get the correct data if I connect the USB (Stlink) cable to the original computer in any of its USB ports.

The Uart2 uses DMA, but that does not matter as I tried the same code with simple _IT calls and got the same results.

Also good to note that I am not using Uart3 which would be connected to the StLink path.

Any ideas? I am completely stumped.

All installations of the STM32CubeIDE are 1.8.0 and all libraries are 1.9.1 (H7)

Also double checked the code that was transferred to make certain it is all identical.

5 REPLIES 5

Perhaps use LEDs to indicate if you fail into the Error_Handler() or HardFault_Handler(), or other places where it could die quietly in a while(1) loop.

Perhaps using GPIO or LEDs to indicate reaching certain code execution check-points, to understand if things are running, and how deep into the code it gets.

Check that clocks are starting properly.

Check that the ST-LINK is not holding the core in reset.

Do some actual debugging on the systems where it isn't working to understand what registers differ or how behaviour deviates from the working system.

Duplicate the issues on multiple boards.

Where multiple systems and/or supplies are involved, ensure the grounds are suitably bonded.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Pavel A.
Evangelist III

Since Ethernet is involved here (and you likely use the 'old' ST driver and examples) - all bets are off.

As Mr. Tesla advised, debug. Maybe use the UART3 to print info (it works independently from the debugger, just as a USB to serial adapter).

Thanks for the ideas.

I can check off the LED indicator for hard faults. That was in there from the start. No indication.

The program is waiting for for the thread that initializes the device on Uart2 to complete (semaphore). The device requires commands to be sent and data retrieved. That is not happening since instead of commands the data is all zeros which the device ignores.

I have measured the 3.3 and 5 when the board is plugged into the different computers and adapters and there is no significant difference.

I have started with a different board.

I am using the SWV port and printf (works great)

GGree.1
Associate III

Ported the same project over to the 746 discovery board and it works regardless of what is supplying power.