Using ITM printf on STM32H723 Nucleo board
- March 8, 2021
- 5 replies
- 12303 views
Hi all,
I'm tying to use the ITM printf on my STM32H723 Nucleo board in my Keil project without success. I configured the HAL with CubeMX and add the initialization for the SWD_Init(). I enabled tracing in Keil but I do not get any output.
I checked:
- SWO solder bridge SB32 on my board.
- The basic clock configuration using a PWM signal.
- I also checked SystemCoreClock variable is set to 550 MHz.
- Updated STM Link Utility to newest version
I have no clue why I can't see any output. I will attach my minimal project example as zip and some screenshots of my Keil Debug config. Hope somebody can help me with this. Keil debugger status bar is red and says no "No Synchronization"
I read the following post:
https://community.st.com/s/question/0D50X00009ce0vWSAQ/nucleoh743zi-board-and-printf-swo-not-working
Same problem without Keil is described here:
https://community.st.com/s/question/0D53W00000bebkzSAA/nucleoh723zg-itm-printf-swv-problems
I already used ITM printf on an STM32H743 processor with Keil in another project without a problem!
Regards Jonny
void SWD_Init(void)
{
*(__IO uint32_t*)(0x5C001004) |= 0x00700000; // DBGMCU_CR D3DBGCKEN D1DBGCKEN TRACECLKEN
//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
//Enable ITM input of SWO trace funnel
*(__IO uint32_t*)(0x5C004000) |= 0x00000001; // SWFT_CTRL
//RCC_AHB4ENR enable GPIOB clock
*(__IO uint32_t*)(0x580244E0) |= 0x00000002;
// Configure GPIOB pin 3 as AF
*(__IO uint32_t*)(0x58020400) = (*(__IO uint32_t*)(0x58020400) & 0xffffff3f) | 0x00000080;
// Configure GPIOB pin 3 Speed
*(__IO uint32_t*)(0x58020408) |= 0x00000080;
// Force AF0 for GPIOB pin 3
*(__IO uint32_t*)(0x58020420) &= 0xFFFF0FFF;
}