cancel
Showing results for 
Search instead for 
Did you mean: 

I have trouble getting ETM instruction trace out of stm32f411ve.

Gowtham shanmugaraj
Associate II

I've configured GPIO for trace , enabled trace in MCUDEBUG and coredebug registers and enabled ETM and started it.when I view the trace pins in a ​logic analyser.. there seems to be no activity on the trace pins. If you have example code for ETM trace using Stm32F4 please provide that.

Thanks in advance​

4 REPLIES 4

Keil had projects and debug configuration files for it ULINKPro and MCBSTM32F400

  _WDWORD(0x40023830, _RDWORD(0x40023830) | 0x00000010); // RCC_AHB1ENR:   IO port E clock enable
  _WDWORD(0x40021000, 0x00002AA0);                       // GPIOE_MODER:   PE2..PE6 = Alternate function mode
  _WDWORD(0x40021008, 0x00003FF0);                       // GPIOE_OSPEEDR: PE2..PE6 = 100 MHz speed
  _WDWORD(0x4002100C, 0x00000000);                       // GPIOE_PUPDR:   PE2..PE6 = No Pull-up/Pull-down
  _WDWORD(0x40021020, 0x00000000);                       // GPIOE_AFRL:    PE2..PE6 = AF0
  _WDWORD(0xE0042004, 0x000000E7);  // DBGMCU_CR Enable 4-bit Trace

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Gowtham shanmugaraj
Associate II

i don't want to use ULINKPRO. I just want to capture the trace pins in a logic analyser. How can I do that? Below is the code i execute after configuring gpio. But i observe no activity on trace pins. What do you think is the problem here?

  DBGMCU->CR |= DBGMCU_CR_TRACE_IOEN;   /* enable trace io */
  DBGMCU->CR |= (3u<<DBGMCU_CR_TRACE_MODE_Pos); /* enable 4 pin data + 1 pin clock */
  
  CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;       /* enable TPIU */
  
  ETF_BASE_PTR->FCR |= 3u; 
    
  ETM_BASE_PTR->LAR = 0xC5ACCE55;       /* unlock ETM registers */
    ETM_BASE_PTR->CR = 0x00001D1Eu;
    while(!((ETM_BASE_PTR->SR) & (1u<<1u)));  
    ETM_BASE_PTR->TRIGGER = 0x0000006Fu;
    ETM_BASE_PTR->EEVR = 0x0000006Fu;    
    ETM_BASE_PTR->TECR1 = 0x00000001u;      
    ETM_BASE_PTR->CR = 0x0000191Eu;    
    while(((ETM_BASE_PTR->SR) & (1u<<1u)));

It was cited as a working example that could be reviewed and probed.

​ARM might have a document for debugger writers. Segger might scripts.

I'll query one of my contacts.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

In the debug configuration file, that keil provides for u link pro, which you mentioned, they do only GPIO configuration... I guess Trace / ETM configuration​ is done by the IDE itself via JTAG if trace is enabled? or you pasted only a part of the script?. It would be really helpful if you can provide some insights..