Question
STM32U575: How to configure the PB3 and the SWO to use ITM_SendChar in plain SWO debugging?
I want to use the SWO tracing without having the debugger configuring the SWO line, so that I can directly get the SWO events, by a proprietary own interface.
I already applied that code: (Still I get no output measuring with the oscilloscope.)
// based on https://developer.arm.com/documentation/ka001424/1-0/?lang=en
// Enabling ITM trace on Serial Wire Viewer
//
// Set TRCENA bit in Debug Exception and Monitor Control Register(DEMCR.TRCENA) to enable access to the trace components' registers.
SET_BIT(CoreDebug->DEMCR, CoreDebug_DEMCR_TRCENA_Msk);
// Select the required pin protocol in the TPIU_SPPR register:
// 0 - parallel synchronous trace port (not SWV)
// 1 - Serial Wire Viewer, Manchester encoding
// 2 - Serial Wire Viewer, UART Non-Return to Zero encoding
// NOT needed default is manchester encoding
// Write 0xC5ACCE55 to the ITM's CoreSight Lock Access Register(ITM_LAR) to unlock the ITM. This register is missing from some editions of the processor's Technical Reference Manual (TRM).
ITM->LAR = 0xC5ACCE55;
// Set ITMENA bit in Trace Control Register(ITM_TCR) to enable the ITM, together with additional bit fields in this register to enable timestamps, synchronization packets, and others as required.
SET_BIT(ITM->TCR, ITM_TCR_ITMENA_Msk);
// Enable the individual channels as required by setting bits in Trace Enable Register(ITM_TER0). You might also wish to control the privilege level of the stimulus channels by writing to the four least significant bits of Trace Privilege Register(ITM_TPR).
SET_BIT(ITM->TER, 1u);
// Set PI PB3 to use the alternative function AF0 (SWO)
GPIO_InitTypeDef GPIO_InitStruct;
/*Configure GPIO pin : */
GPIO_InitStruct.Pin = GPIO_PIN_3;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Alternate = GPIO_AF0_TRACE;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
ITM_SendChar('R');When I use CubeIDE debugging having the SWO enabled, the character is send and I see the communication on the SWO line with the oscilloscope and the SWV ITM data console.
Does anyone has an idea what I miss?
