cancel
Showing results for 
Search instead for 
Did you mean: 

STM32WB55 Trace Configuration Issue - No Trace Data

TAtte.1
Associate II

I've been working with the STM32WB55 microcontroller and have been trying to set up 4 bit trace functionality (ETM, not SWO) for debugging. I've connected the trace pins according to the datasheet and configured them in the STM32Cube software.

Specifically, the trace GPIO's have been configured as alternative function pins as shown here:

 

    __HAL_RCC_GPIOC_CLK_ENABLE();
    __HAL_RCC_GPIOD_CLK_ENABLE();
    __HAL_RCC_GPIOE_CLK_ENABLE();    

    // 4. Initialize the speed for the Trace Clock and Trace Data signals
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

    // 5. Begin the process of configuring the GPIO pins for trace functionality
    // TRACECLK
    GPIO_InitStruct.Pin = GPIO_PIN_2;
    GPIO_InitStruct.Alternate = GPIO_AF0_TRACECK;
    HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);

    // 6. Repeat these configuration steps for each trace data pin
    // TRACED0
    GPIO_InitStruct.Pin = GPIO_PIN_9;
    GPIO_InitStruct.Alternate = GPIO_AF0_TRACED0;
    HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);

    // TRACED1
    GPIO_InitStruct.Pin = GPIO_PIN_10;
    GPIO_InitStruct.Alternate = GPIO_AF0_TRACED1;
    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

    // TRACED2
    GPIO_InitStruct.Pin = GPIO_PIN_2;
    GPIO_InitStruct.Alternate = GPIO_AF0_TRACED2;
    HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);

    // TRACED3
    GPIO_InitStruct.Pin = GPIO_PIN_12;
    GPIO_InitStruct.Alternate = GPIO_AF0_TRACED3;
    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

// 7. Enable trace functionality
    // Set the PRESCALER in the Asynchronous Clock Prescaler Register (ACPR)
    TPI->ACPR = (TPI->ACPR & ~TPI_ACPR_PRESCALER_Msk) | ((prescaler_value << TPI_ACPR_PRESCALER_Pos) & TPI_ACPR_PRESCALER_Msk);

    // Set the TXMODE: 0x0: Parallel trace port mode, only available on STM32WB55xx
    TPI->SPPR = (TPI->SPPR & ~TPI_SPPR_TXMODE_Msk) | ((0x0 << TPI_SPPR_TXMODE_Pos) & TPI_SPPR_TXMODE_Msk);

    // Enable continuous formatting and comparison in the Formatter and Flush Control Register (FFCR)
    TPI->FFCR |= TPI_FFCR_EnFCont_Msk;

 

However, when I attempt to capture the trace output, I'm not observing any signal on any TRACE pin.

I've double-checked the wiring and configuration in STM32Cube, and everything appears to be correct. The clock settings and peripheral clocks in my system configuration also seem to be fine. I've also attempted to reset the MCU and debug tools multiple times.

Does anyone have any ideas what might be going wrong here, or any troubleshooting steps that I could try? Any advice would be greatly appreciated!

1 REPLY 1
TAtte.1
Associate II

I found the solution within 10 minutes of posting. Answer is this:

LL_DBGMCU_EnableTraceClock();

__STATIC_INLINE void LL_DBGMCU_EnableTraceClock(void)
{
SET_BIT(DBGMCU->CR, DBGMCU_CR_TRACE_IOEN);
}