cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H757 SWO Debug Error

MA4
Associate III

Hello,

Hello,
I am experiencing the same issues as these individuals : https://community.st.com/t5/stm32-mcus-products/stm32h757-swo-debug-error/m-p/738531#M265220

When I launch my debug with SWO enabled, I encounter errors upon launch, and if the errors are not displayed, the prints do not works, even though I have already used them on other projects with other processors and they worked.

I have follow instructions to activate sw (enable two, set clock, set prescaler, use ITM console,  ...)

my print function is :

int __io_putchar(int ch)

{

ITM_SendChar(ch);

return(ch);

}



But I have the error, so I try lot of things,  
* change cables and PC port
* change my PC (Mac and Windows) (STM32CubeIDE 1.18.0)
* set script to set sw register, in Debug Configurations > startup > Run commands

* set by my self swo pin (see below)

* do my own swo_init function called in main after GPIO init (see below)

 

Nothing works, can someone help me ?

 

{

GPIO_InitTypeDef GPIO_InitStruct = {0};

GPIO_InitStruct.Pin = 1 << SWO_PIN;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

GPIO_InitStruct.Alternate = GPIO_AF0_SWJ;

HAL_GPIO_Init(SWO_PORT, &GPIO_InitStruct);

}

static void SWO_Init(uint32_t coreClockHz, uint32_t swoSpeedHz)

{

// Enable TRACECLK (optional depending on family)

CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;

 

// Unlock ITM

ITM->LAR = 0xC5ACCE55;

 

// Enable ITM and stimulus port 0

ITM->TCR = ITM_TCR_ITMENA_Msk | ITM_TCR_SYNCENA_Msk | ITM_TCR_TSENA_Msk | ITM_TCR_SWOENA_Msk;

ITM->TER = 0x1; // Enable stimulus port 0

 

// Configure DWT

DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;

 

// Configure TPIU

TPI->ACPR = (coreClockHz / swoSpeedHz) - 1; // Set SWO speed

TPI->SPPR = 0x00000001; // NRZ / UART protocol

TPI->FFCR = 0x00000100; // Disable formatting

TPI->CSPSR = 1; // Port size = 1 bit

}

 

0 REPLIES 0