2025-05-29 7:56 PM
I have enabled Serial Wire Viewer (SWV) in my m55 application as I have done with my m4 and m33 projects, but the printf is not appearing in the SWV view.
Are there additional setup required on the NUCLEO-N657 board such as jumper settings or additional software setup?
Thank you.
Solved! Go to Solution.
2025-05-30 10:54 AM
@KDJEM.1 Thank you. Dividing the CPU clock by 8 resolved my issue.
2025-05-30 7:26 AM - edited 2025-05-30 7:28 AM
Hello @kag_embedded;
Could you please make sure that you:
- Enable TRACE CLOCK AND DEBUG CLOCK in DBGMCU register
- The SWV core clock in STM32CUBEIDE should always be CPU clock/8, the SWV core clock should be 8Mhz
- Configure the SWV ITM Data console
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####################
For more information about Serial Wire Viewer I recommend you to look at AN4948 precisely section "7.3 Printf via SWO/SWV"
If you want also to see the UART output message on the HyperTerminal, I recommend you to look at UART_Printf example.
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.
2025-05-30 10:54 AM
@KDJEM.1 Thank you. Dividing the CPU clock by 8 resolved my issue.