cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot view any ITM data on Debug (printf) Viewer in Keil for STM32H743

HKapo.1
Associate III

Hello All,

We are trying to get some debug trace info from our project and trying to use ITM for the same.

For our product we are using the follwoing:

STM32H743

Keil Version 5.24.1

ULINK 2 debugger

I created a simple project following many forum topics and the source code is:

/* USER CODE END 0 */
    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;
    }
/**
  * @brief  The application entry point.
  * @retval int
  */
int main(void)
{
  /* USER CODE BEGIN 1 */
 
  /* USER CODE END 1 */
 
  /* MCU Configuration--------------------------------------------------------*/
 
  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();
 
  /* USER CODE BEGIN Init */
 
  /* USER CODE END Init */
 
  /* Configure the system clock */
  SystemClock_Config();
 
  /* USER CODE BEGIN SysInit */
	
	SWD_Init();
HAL_Delay(500);
  /* USER CODE END SysInit */
 
  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_USART1_UART_Init();
  /* USER CODE BEGIN 2 */
	ITM_SendChar('a');
	printf("Hello World");
  /* USER CODE END 2 */
 
  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
		ITM_SendChar('a');
		HAL_Delay(500);
    /* USER CODE END WHILE */
 
    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}

and using Keil's retarget_io.c

Our trace settings looks like this:

0693W00000WJQqsQAH.png 

The trace seems to be running but no output.

Can someone guide us as to what is missing.

0693W00000WJQr7QAH.png

7 REPLIES 7

The enabling code was for the ST-LINK originally, not the U-LINK, so you'd need to know the clocking, and its not 1 MHz. The ST-LINK/V2 SWO Clock was 2 MHz, the V3 I think is 15 MHz, the current DLLs might be more aware now.

Typically you need to setup the Trace with the Frequency you're running the MCU, and look at the SWO clock.

Port 7..0 should be checked too.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Pavel A.
Evangelist III

In the Core Clock field put the value of SystemCoreClock global variable after SystemClock_Config call (in MHz: 400000000 -> 400.0)

ITM_SendChar should work after the core clock becomes equal to that value.

Check in port 0 should be enough for ITM_SendChar.

HKapo.1
Associate III

Hello,

Many thanks for your reply. I have now done the setup as per your suggestion (i.e removed call to SWD_Init and changed core clock):

0693W00000WJcR1QAL.png 

But now getting "Trace No synchronization" and also still can't see any message

0693W00000WJcRpQAL.png 

What version of Keil?

Still suggestive of pin level connective or clock disparity.

Sorry know nothing about your design or implementation. ​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Hello,

Below is our Keil Version

0693W00000WJccdQAD.png 

Also I have set the clock to be 400 Mhz:

0693W00000WJcdHQAT.png 

We have our custom board with 20 Mhz crystal and also SWD pins are corrected to micro correctly.

Hello

Can someone please guide me to resolve this issue

For STM32H7 you likely have the full version of MDK. So, https://www.keil.com/support/