cancel
Showing results for 
Search instead for 
Did you mean: 

STM32N6 ITM console

PeterPan
Associate II

Hello,

I have custom board with STM32N6. I followed guidelines how to enable the ITM console:

https://community.st.com/t5/stm32-mcus/using-the-itm-console-for-printf-redirects-and-lwip-debug/ta-p/723472

The System Core Clock is set to 600MHz, confirmed with variable SystemCoreClock=600. The Trace Anynchronus Sw is selected and PB3 connected.
Simple ITM_SendChar(101); gets executed but no output in the console. I tried 600MHz core clock for the Serial Wire Viewer, also many other clock frequencies like 75MHz (TPIU clock), but none is working.

Are there any special steps to configure ITM console on STM32N6?

1 ACCEPTED SOLUTION

Accepted Solutions
PeterPan
Associate II

Found the problem. I overlooked the datasheet. The SWO pin cannot be multiplexed between PB5 and PB3 - which is reserved for trace clock.

The CubeMX labels PB3 as [SWO_PB3] DEBUG_JTDO-SWO (Debug Trace Asynchronous SW) so I assumed it could output SWO trace.

View solution in original post

3 REPLIES 3
KDJEM.1
ST Employee

Hello @PeterPan and welcome to the community;

 

The SWV core clock in STM32CubeIDE should always be CPU clock/8.

Make sure that the start trace is enabled.

I recommend you to look at this post and this post and get inspired to check the settings:

KDJEM1_0-1760087920115.png

 

KDJEM1_1-1760087918917.png

 

KDJEM1_2-1760087920191.png

I advise you starting by simulating a simple printf code without lwip.

Below an code example of printf:

################CODE BEGIN####################

int __io_putchar(int ch)
 {
   ITM_SendChar(ch);
   return(ch);
 }


int main(void)
{
 GPIO_InitTypeDef gpio_init;

DBGMCU->CR |=0x00300000;
 ITM->TER |= 0x1;
 ITM->TCR |= 0x00001;

  //SWO is Ball U12 or PB5 label on N6
  __HAL_RCC_GPIOB_CLK_ENABLE();
  gpio_init.Mode   = GPIO_MODE_AF_PP;
  gpio_init.Pull   = GPIO_PULLUP;
  gpio_init.Speed   = GPIO_SPEED_FREQ_HIGH;
  gpio_init.Pin    = GPIO_PIN_5;
  gpio_init.Alternate = GPIO_AF0_TRACE;
  HAL_GPIO_Init(GPIOB, &gpio_init);


  HAL_Init();

  /* Initialize LED1 */
  BSP_LED_Init(LED_GREEN);

  while (1)
  {
    /* Toggle LED1 every 500ms */
    BSP_LED_Toggle(LED_GREEN);
    HAL_Delay(500);
    printf("Hello world\n");
  }
}

################CODE END####################

 

I hope this help you.

 

Thank you.

Kaouthar

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.

PeterPan
Associate II

 Hello @KDJEM.1, thank you for your support.

The console is configured according to your recommendations. I created new, bare project to check configurations with your code.

I see the SWO outputs continuous 37.5MHz clock, no serial stream visible.

 

clocks.png

PeterPan
Associate II

Found the problem. I overlooked the datasheet. The SWO pin cannot be multiplexed between PB5 and PB3 - which is reserved for trace clock.

The CubeMX labels PB3 as [SWO_PB3] DEBUG_JTDO-SWO (Debug Trace Asynchronous SW) so I assumed it could output SWO trace.