Skip to main content
matt-crc
Senior III
February 17, 2026
Solved

STM32N657: can't get the debug SWO port to work

  • February 17, 2026
  • 1 reply
  • 225 views

Hello,

I'm starting a new project with the N657 device.  I can't get the debug SWO port to work.

1- I'm redirecting the putchar to the SWO port:

int __io_putchar(int c) {
	ITM_SendChar(c);
	// HAL_UART_Transmit(&huart3, (uint8_t *)&ch, 1, 0xFFFF);
	return (c);
}

2- The trace and debug clock is set to 8mhz

mattcrc_0-1771307694336.png

3- In the debugger setup, i enabled the port and set it to 8mhz

mattcrc_1-1771307792438.png

4- in the debugger, I enable trace 0, and enabled it.  

mattcrc_2-1771307894172.png

Nothing ever seems to get sent to this window.  Note: I know the cable/usb dongle is good since it works with the h743.   Does anyone have any suggestions?

thanks

Matthew

 

 

Best answer by matt-crc

Hi @Souhaib MAZHOUD 

The new STM32 device (N657) does not use the same debug core as with older MCUs, and the debug clock speed is no longer associated with the CPU core clock.  Now there is a dedicated branch in the clock tree configuration named TPIU Clock.

mattcrc_0-1771353095794.png

I read somewhere that the TPIU clock should be set to 8MHz.  Then the same frequency must be entered in the Debugger setting page:

mattcrc_1-1771353246007.png

This did not work at first.  I then played with the "Limit SWO clock" option in the debugger and limited the SWO clock to 2MHz.  

mattcrc_2-1771353328366.png

Now, when I enter the debugger, I see that it detected the correct clock settings with the correct pre-scaler:

mattcrc_3-1771353444778.png

and now the serial wire viewer works properly in CubeIDE...

Matt

 

 

1 reply

Technical Moderator
February 17, 2026

Hello @matt-crc 

I assume that this post might be useful. Ensure that the CPU core clock configured in the debug settings matches the running core clock, including any PLL settings.

KR, Souhaib

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.
matt-crc
matt-crcAuthorBest answer
Senior III
February 17, 2026

Hi @Souhaib MAZHOUD 

The new STM32 device (N657) does not use the same debug core as with older MCUs, and the debug clock speed is no longer associated with the CPU core clock.  Now there is a dedicated branch in the clock tree configuration named TPIU Clock.

mattcrc_0-1771353095794.png

I read somewhere that the TPIU clock should be set to 8MHz.  Then the same frequency must be entered in the Debugger setting page:

mattcrc_1-1771353246007.png

This did not work at first.  I then played with the "Limit SWO clock" option in the debugger and limited the SWO clock to 2MHz.  

mattcrc_2-1771353328366.png

Now, when I enter the debugger, I see that it detected the correct clock settings with the correct pre-scaler:

mattcrc_3-1771353444778.png

and now the serial wire viewer works properly in CubeIDE...

Matt