AnsweredAssumed Answered

STM32W108: SWO trace not working

Question asked by kashlikov.sergey on Mar 26, 2014
Latest reply on Apr 1, 2014 by nouha
Hello, 

I cannot start SWO trace (nothing received in debug window) with STM32W108CB. I have standard configuration of ITM, listed below. And i configured the 33 pin for SWO with line "REG_GPIOC->CRL = 0x900;".
Software used is uVision 4.76, jtag ULINK2.

01.static int Debug_ITMDebug = 0;
02. 
03. 
04. 
05.void InitializeTrace(void)
06.{
07.    volatile uint *ITM_TER      = (volatile uint *)0xE0000E00;
08.    volatile uint *SCB_DHCSR    = (volatile uint *)0xE000EDF0;
09. 
10.   *SCB_DHCSR = 0x30003;
11.   *((volatile uint *)0xE000EDFC) = 0x01000000;   // "Debug Exception and Monitor Control Register (DEMCR)"
12.   *((volatile uint *)0xE0042004) = 0x00000027;
13.   *((volatile uint *)0xE00400F0) = 0x00000002;   // "Selected PIN Protocol Register": Select which protocol to use for trace output (2: SWO)
14.   *((volatile uint *)0xE0000FB0) = 0xC5ACCE55;   // ITM Lock Access Register, C5ACCE55 enables more write access to Control Register 0xE00 :: 0xFFC
15.   *((volatile uint *)0xE0000E80) = 0x00010009;   // ITM Trace Control Register
16.   *((volatile uint *)0xE0000E40) = 0x0000000F;   // ITM Trace Privilege Register
17.   *((volatile uint *)0xE0000E00) = 0x00000001;   // ITM Trace Enable Register. Enabled tracing on stimulus ports. One bit per stimulus port.
18.   *((volatile uint *)0xE0001000) = 0x400003FE;   // DWT_CTRL
19.   *((volatile uint *)0xE0040304) = 0x00000100;   // Formatter and Flush Control Register
20. 
21.    if ((*SCB_DHCSR & 1) && (*ITM_TER & 1)) // Enabled?
22.        Debug_ITMDebug = 1;
23.}
24. 
25. 
26. 
27.void TraceChar(char ch)
28.{
29.    static volatile unsigned int *ITM_STIM0 = (volatile unsigned int *)0xE0000000; // ITM Port 0
30.    static volatile unsigned int *SCB_DEMCR = (volatile unsigned int *)0xE000EDFC;
31. 
32.    if (Debug_ITMDebug && (*SCB_DEMCR & 0x01000000))
33.    {
34.        while (*ITM_STIM0 == 0);
35. 
36.        *((volatile char *)ITM_STIM0) = ch;
37.    }
38.}

Outcomes