Percepio Trace SWV Issue

All design tool related questions: compiler, assembler, linker. Embedded programming questions: assembler, C code.

Moderator: nferre

Posts: 1
Joined: Fri Sep 12, 2014 6:35 pm

Percepio Trace SWV Issue

Fri Sep 12, 2014 7:09 pm


I have a SAM4S application that prints debug messages on SWO. I have verified that the outputs work using the J-Link SWO Viewer application. However, when I try to run Percepio Trace, I see nothing in the "Output" window and no "message events" appear on the Control Flow Diagram. (Control flow works, though...) Has anyone else encountered this?

My best guess is that it has to do with how I'm initializing the ITM unit and how Percepio manipulates those registers? I'd prefer to have the debug tool set the ITM registers rather than doing it in code, but that didn't work for the J-Link SWO Viewer I was using for initial testing... I'm testing on a SAM4S-EK2, and here's the relevant code bits:

Code: Select all

//! Initializes the ITM port
static inline void stdio_itm_init(void)
#if SAM
  // Configure the redirection
  stdio_base = (void *) 0xE0000000;
  ptr_put = (int (*)(void volatile*,char))&stdio_itm_putc;
  ptr_get = (void (*)(void volatile*,char*))&stdio_itm_getc;
  // Initialize the ITM unit
  uint32_t SWOSpeed = 6000000;
  CoreDebug->DEMCR = CoreDebug_DEMCR_TRCENA_Msk;   // "Debug Exception and Monitor Control Register (DEMCR)"
  TPI->SPPR = 0x00000002;   // "Selected PIN Protocol Register": Select which protocol to use for trace output (2: SWO)
  TPI->FFCR = TPI_FFCR_TrigIn_Msk;   // Formatter and Flush Control Register
  uint32_t SWOPrescaler = ((sysclk_get_cpu_hz() / SWOSpeed) - 1) & TPI_ACPR_PRESCALER_Msk;  // SWOSpeed in Hz
  TPI->ACPR = SWOPrescaler; // "Async Clock Prescaler Register". Scale the baud rate of the asynchronous output
  *((volatile unsigned *)0xE0000FB0) = 0xC5ACCE55;   // ITM Lock Access Register, C5ACCE55 enables more write access to Control Register 0xE00 :: 0xFFC
  ITM->TCR = 0x00010015;   // ITM Trace Control Register
  ITM->TER = 0x00000001;   // ITM Trace Enable Register. Enabled tracing on stimulus ports. One bit per stimulus port.
  ITM->TPR = 0x00000001;   // ITM Trace Privilege Register
# error Unsupported chip type

Code: Select all

/** \brief  ITM Send Character
    The function transmits a character via the ITM channel 0, and
    \li Just returns when no debugger is connected that has booked the output.
    \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted.
    \param [in]     ch  Character to transmit.  
    \returns            Character to transmit.
__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch)
  if ((ITM->TCR & ITM_TCR_ITMENA_Msk)                  &&      /* ITM enabled */
      (ITM->TER & (1UL << 0)        )                    )     /* ITM Port #0 enabled */
    while (ITM->PORT[0].u32 == 0);
    ITM->PORT[0].u8 = (uint8_t) ch;
  return (ch);

Return to “Development Tools”

Who is online

Users browsing this forum: No registered users and 1 guest