AnsweredAssumed Answered

TWR-K65F180M no trace synchronization on 4-bit port

Question asked by Adam Drewery on Jan 12, 2017
Latest reply on Jan 24, 2017 by Tc Liew

We are hoping to gain some clarity on using the 4-bit trace port of the TWR-K65F180M. I'm going to include everything we've tried here as it may help someone else as well.

 

Initially, we were having issues even getting JTAG to work. We followed the guidelines to remove the shunt on J32, but this did not allow us to utilize JTAG. We updated the bootloader firmware per this forum post:

JTAG in TWR-K65F180M not functional on rev A0 

Note: The forum response from Natish Harish contains the binary file you will want to use. I missed it the first few times.

 

After that, we were still unable to use JTAG. We then added 0 Ohm resistors for R54 - R58 (for the trace functionality) and R68, R69. This got us going with JTAG debugging. However, we are still having issues using the 4-bit trace mode.

 

We followed all of the configuration guidelines here:

ULINKpro User's Guide: Enable 4-Pin Trace (ETM) 

 

As the above link was for the K70, we modified it to point to the addresses of the corresponding registers on the K65. Our resultant initialization file is:

/*-------------------------------------------------------------------
** Define the function to enable the trace port
**-----------------------------------------------------------------*/
FUNC void SetupTrace(void) {

  _wDWORD(0x40048038,(_RDWORD(0x40048038) | 0x00002000));      // SIM_SCGC5  : Enable PORT E clock
  _wDWORD(0x40048004,(_RDWORD(0x40048004) | 0x00001000));      // SIM_SOPT2  : Trace Clock Source is set as "Core/system clock"
  _wDWORD(0x40048068,(_RDWORD(0x40048068) & 0xFFFFFFF0));      // SIM_CLKDIV4: Set TRACEDIV = b000 & TRACEFRAC = b0
                                                               // Note: Do not change the value of SIM_CLKDIV4[0..3] in your application!
  _wDWORD(0x4004D000, 0x00000740);  // PTE0: TraceClock, High drive strength
  _wDWORD(0x4004D004, 0x00000740);  // PTE1: TRACED3   , High drive strength
  _wDWORD(0x4004D008, 0x00000740);  // PTE2: TRACED2   , High drive strength
  _wDWORD(0x4004D00C, 0x00000740);  // PTE3: TRACED1   , High drive strength
  _wDWORD(0x4004D010, 0x00000740);  // PTE4: TRACED0   , High drive strength
}

/*-------------------------------------------------------------------
** Invoke the function at debugger startup
**-----------------------------------------------------------------*/
SetupTrace();

/*-------------------------------------------------------------------
** Execute upon software RESET
**-----------------------------------------------------------------*/
FUNC void OnResetExec(void)  {
  SetupTrace();
}

We have gotten some of the trace functionality to work but not with the 4-bit trace mode. We have tried changing our debugger clock speeds, and we have tried with matched/mis-matched core clock settings.

 

We have had success when using the ETB and slowing the debug clock down, but we do not see anything in the Event Viewer window. When we step through the code we can use ETB we are able to log several thousand (highest I saw was 7500 events), but if we just let it run we stop logging ETM after around 10 seconds. Using SWO - Manchester we can only see ITM data, and we see the events in the Event Viewer window. Similar to running the ETM port, we have to step through in order to log more than several thousand events.

 

We did have a few questions:

The Core Clock field needs to match the frequency of the actual clock on the MCU. Does it also need to match the Xtal field in the Target settings tab? The description makes it sound like the Xtal field should match the frequency of the external oscillator.

Do we need to install a 0 Ohm on R53?

In our initialization file, do we need to change the pin mulitplexing? The example did not do this, but it would seem to me that we ought to be assigning the multiplex assignment.

Are there any limitations for the 4-bit trace port that we are overlooking?

 

Any help would be greatly appreciated.

 

Thanks,

Adam

Outcomes