No trace SWO output on stm32H743VIT6. SWO printf not working
Hello.
Hi Forum. I am new to the H743 line of processors and the first thing I tried is getting printf() output on the traceswo pin of my nucleo-H743ZI. What I have tried:
1. The 'Everything out of the box' way:
Use cubeMX to configure sys to async trace, configure clocks, enable master clock out (to verify clock speed with a logic analyser).
Import the project to stm32cubeide and configure debugging to use the SWF, with the specific baud rate and core clock.
Write simples main loop:
while(1)
{
ITM_Sendchar('E');
HAL_Delay(2000);
}Start a debugging session, configure trace port 0 and start tracing -> no output in atollic truestudio, no output on PB3 (verified with logic analyser)
I' m add example of Initialization file
uint32_t SystemCoreClock = 480000000;
void DebugSetup (void)
{
DBGMCU->CR |= DBGMCU_CR_DBG_CKD3EN | DBGMCU_CR_DBG_CKD1EN | DBGMCU_CR_DBG_TRACECKEN;
//UNLOCK FUNNEL
*(__IO uint32_t*)(0x5C004FB0) = 0xC5ACCE55; // SWTF_LAR
*(__IO uint32_t*)(0x5C003FB0) = 0xC5ACCE55; // SWO_LAR
//SWO current output divisor register
//This divisor value (0x000000C7) corresponds to 400Mhz
//To change it, you can use the following rule
// value = (CPU Freq/sw speed )-1
*(__IO uint32_t*)(0x5C003010) = ((SystemCoreClock / 2000000) - 1); // SWO_CODR
//SWO selected pin protocol register
*(__IO uint32_t*)(0x5C0030F0) = 0x00000002; // SWO_SPPR NRZ
//Enable ITM input of SWO trace funnel
*(__IO uint32_t*)(0x5C004000) |= 0x00000001; // SWFT_CTRL
MODIFY_REG(GPIOB->MODER, GPIO_MODER_MODE3, 0x2 << GPIO_MODER_MODE3_Pos);
MODIFY_REG(GPIOB->OSPEEDR,GPIO_OSPEEDR_OSPEED3,0x0 << GPIO_OSPEEDR_OSPEED3_Pos);
MODIFY_REG(GPIOB->PUPDR, GPIO_PUPDR_PUPD3, 0x00 << GPIO_PUPDR_PUPD3_Pos);
MODIFY_REG(GPIOB->AFR[0], GPIO_AFRL_AFSEL3, 0x0 << GPIO_AFRL_AFSEL3_Pos);
}__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch)
{
if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */
((ITM->TER & 1UL ) != 0UL) )
{
while (ITM->PORT[0U].u32 == 0UL)
{
__NOP();
}
ITM->PORT[0U].u8 = (uint8_t)ch;
}
return (ch);
}Start a debugging session, configure trace port 0 and start tracing -> no output in atollic truestudio, no output on PB3 (verified with logic analyser)
