How to enable SWO debug with MCX-N9XX-EVK

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How to enable SWO debug with MCX-N9XX-EVK

1,122件の閲覧回数
threeboystech
Contributor II

I've enabled SWO output on pin P0_2 for SWO and called the following Init() method, but the SWO_WriteBuf() does not provide any output. 

 

Can someone link me to what I may be doing wrong or an example on how to configure this?

Thanks

 

static inline bool SWO_WriteChar(char c, uint8_t portNo) {

volatile int timeout = 5000; /* arbitrary timeout value */

while (ITM->PORT[portNo].u32 == 0) {

/* Wait until STIMx is ready, then send data */

timeout--;

if (timeout==0) {

return false; /* not able to send */

}

}

ITM->PORT[portNo].u8 = c;

return true;

}

 

static void SWO_WriteBuf(char *buf, size_t count, uint8_t portNo) {

while(count>0) {

SWO_WriteChar(*buf, portNo);

buf++;

count--;

}

}

/*!

* \brief Initialize the SWO trace port for debug message printing

* \param portBits Port bit mask to be configured

* \param cpuCoreFreqHz CPU core clock frequency in Hz

*/

static void Init(uint32_t traceClockHz, uint32_t SWOSpeed, uint32_t port)

{

CoreDebug->DEMCR = CoreDebug_DEMCR_TRCENA_Msk;

if ((CoreDebug->DEMCR & CoreDebug_DEMCR_TRCENA_Msk) == 0U) {

assert(false);

}

ITM->LAR = 0xC5ACCE55U; /* ITM Lock Access Register, C5ACCE55 enables more write access to Control Register 0xE00 :: 0xFFC */

ITM->TER &= ~(1UL << port); /* ITM Trace Enable Register. Enabled tracing on stimulus ports. One bit per stimulus port. Disable it */

ITM->TCR = 0U; /* ITM Trace Control Register */

TPI->SPPR = 0x2; /* "Selected PIN Protocol Register": Select which protocol to use for trace output (2: SWO NRZ (UART), 1: SWO Manchester encoding) */

SetSWOSpeed(traceClockHz, SWOSpeed); /* set baud rate with prescaler */

ITM->TPR = 0U; /* allow unprivileged access */

ITM->TCR = ITM_TCR_ITMENA_Msk | ITM_TCR_SYNCENA_Msk /* enable ITM */

#ifdef ITM_TCR_TraceBusID_Msk

| ITM_TCR_TraceBusID_Msk

#elif defined(ITM_TCR_TRACEBUSID_Msk)

| ITM_TCR_TRACEBUSID_Msk

#endif

| ITM_TCR_SWOENA_Msk | ITM_TCR_DWTENA_Msk;

ITM->TER = 1UL << port; /* enable the port bits */

}

ラベル(1)
0 件の賞賛
返信
1 返信

1,068件の閲覧回数
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @threeboystech 

For SWO function,  If you use MCUXpresso IDE, I recommend you refer to  <MCUXpresso IDE SWO Trace Guide>. I attach it for you. Thanks.

 

BR

Alice

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0 件の賞賛
返信