Enabling SWO on MCXN947DK

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Enabling SWO on MCXN947DK

Jump to solution
1,216 Views
jcallon
Contributor III

Hello,

I'm trying to enable SWO on my MCXN947, but am having trouble getting it to output anything.

 

  1. I have the SWO pin routed in MCUxpresso.
    jcallon_0-1762968661637.png
  2. I have TRACE_CLK enabled, and set to half the speed of the main clock, because MCUxpresso does not let me set a TRACE_CLK speed above 96MHz .
    jcallon_1-1762968731658.png
    jcallon_2-1762968763955.png
    jcallon_3-1762968919749.png
  3. I use DebugConsole_Init(0, 2000000, kSerialPort_Swo, 75000000); to initialize SWO. Because I have SDK_DEBUGCONSOLE=1U and SERIAL_PORT_TYPE_SWO=1U, this flow is called. It finishes without error.
    FileFunction
    fsl_debug_console.cDbgConsole_Init
    fsl_debug_console.cSerialManager_Init
    fsl_component_serial_port_swo.cSerial_SwoInit
    fsl_debug_console.c
    SerialManager_OpenWriteHandle
    fsl_debug_console.c
    SerialManager_OpenReadHandle
  4. I use DebugConsole_PutChar('H') to try and output a byte on SWO, in an infinite loop. Because I have SDK_DEBUGCONSOLE=1U and SERIAL_PORT_TYPE_SWO=1U, this flow is called. It finishes without error.
    FileFunction
    fsl_debug_console.cDbgConsole_Putchar
    fsl_debug_console.c
    DbgConsole_SendDataReliable
    fsl_component_serial_manager.c
    SerialManger_WriteBlocking
    fsl_component_serial_manager.cSerialManger_Write
    fsl_component_serial_manager.cSerialManager_StartWriting
    fsl_component_serial_port_swo.cSerial_SwoWrite

 

After all this, I see no output on SWO. It is simply held high by my SEGGER J-Link.

jcallon_4-1762969688166.png

 

Please let me know if there is some setup I am missing!
Otherwise, if someone has a working SWO setup on their own MCXN947DK, I'd really appreciate seeing your code and setup.

Thank you very much!
JC

Labels (3)
0 Kudos
Reply
1 Solution
919 Views
jcallon
Contributor III

An update, in case it helps someone out.

In my first post I mentioned using DbgConsole_Init(..., kSerialPort_Swo, ...) to initialize my SWO registers. Turns outs, all that was needed after that to make SWO be outputted for me was to enable the CoreSight Funnel Lock Access Register.

// https://developer.arm.com/documentation/100536/0302/About-the-programmers-model/ATB-funnel-registers/ATB-funnel-register-summary
uint32_t *CSFUNNEL_LAR = (uint32_t *)(TPIU_BASE + 0x4000 + 0xFB0);
*CSFUNNEL_LAR = 0xC5ACCE55;

 

I'm still interested in hearing how I can use MCUxpresso to set registers to get more interesting analytics over SWO than just printing characters, which is my current setup.

View solution in original post

0 Kudos
Reply
7 Replies
1,191 Views
EdwinHz
NXP TechSupport
NXP TechSupport

Hi @jcallon,

For the proper procedure of executing SWO on our devices, please follow this guide: https://www.nxp.com/webapp/Download?colCode=MCUXPRESSO-SWO-TRACE&appType=license&location=null.

BR,
Edwin.

0 Kudos
Reply
1,188 Views
jcallon
Contributor III

Thank you Edwin. I've seen that guide before, but I'll review it again in case I missed anything. It has many useful examples in the appendix for LPC* chips, but none I could fine for MCXN* chips.

0 Kudos
Reply
1,180 Views
jcallon
Contributor III

Hi again,

To try and follow the posted guide, I've been trying to use SWO Trace Config to configure my SWO, instead of the DebugConsole_Init.

  1. Load the frdmmcxn947_led_blinky_cm33_core0 example into the MXUxpresso IDE.
  2. Mux SWO
    jcallon_0-1762987836579.png
  3. My use case requires a 150MHz clock. Enable 150MHz clock by changing 'Initalize USBPHY clock' to 'PLL only'. Change BOARD_InitHardware(...) hardware_init.c to call BOARD_BootClockPLL150M(...) instead of BOARD_BootClockFRO12M(...), and update SysTick_Config(...) from to 12000000 to 150000000.
    jcallon_2-1762988019244.png
  4. Set TRACECLK to 75 Mhz (because 96MHz is max).

     

    jcallon_3-1762988087308.png
  5. Click Update Code.
  6. Click Debug.
  7. Click Resume All Debug sessions.
  8. Open SWO Trace Config.
  9. Click Change to configure main and trace clock speed.
    jcallon_4-1762988169215.png
  10. Get an error. Are certain baud rates expected?
    jcallon_5-1762988685892.png

     

If you can, let me know if this issue reproduces on your side.
Thank you,
JC

0 Kudos
Reply
1,093 Views
EdwinHz
NXP TechSupport
NXP TechSupport

Hi @jcallon,

I tried to replicate your issue with a FRDM-MCXN947, so I followed the same steps that you shared.

However, I noted something on step 3; You mentioned that your use case "requires a 150MHz clock. Enable 150MHz clock by changing 'Initalize USBPHY clock' to 'PLL only'."

That said, the frdmmcxn947_led_blinky_cm33_core0 example project already enables the main clock to be 150MHz, and the Functional Group is already BOARD_BootClockPLL150M. So, I didn't have to make any changes in the Clocks Tool, other than enabling the Trace Clock and setting it to 75MHz.

I didn't even have to enable the SWO pin, as it is also enabled on the example code already.

Are you using the latest release of the SDK?

On my side, I only had to do step 1, 4, 5, 6, 7, 8 and 9, and it worked correctly, without any error message regarding the baudrate.

 

 

0 Kudos
Reply
1,085 Views
jcallon
Contributor III

Thank you Edwin.

I was using MCUxpresso 24.12, and updated to the latest I could find, 25.6.
Sure enough, when using the new MCUxpresso, like you said, the main clock was already configured 150MHz and SWO was already muxed.

Now, SWO trace config can find my board, at a clock speed of 150MHz, and a trace clock speed of 75MHz. I'm really happy MCUxpresso can find it now!

However, I did notice that after SWO Trace Config connected, the blinky on my board stopped running, and connection may not be complete. In screenshots from the MCUXpresso IDE Linkserver SWO Trace Guide, all dots on the right were green, for example, probe backend. Did you see this on your side?

jcallon_0-1763167503999.png

0 Kudos
Reply
920 Views
jcallon
Contributor III

An update, in case it helps someone out.

In my first post I mentioned using DbgConsole_Init(..., kSerialPort_Swo, ...) to initialize my SWO registers. Turns outs, all that was needed after that to make SWO be outputted for me was to enable the CoreSight Funnel Lock Access Register.

// https://developer.arm.com/documentation/100536/0302/About-the-programmers-model/ATB-funnel-registers/ATB-funnel-register-summary
uint32_t *CSFUNNEL_LAR = (uint32_t *)(TPIU_BASE + 0x4000 + 0xFB0);
*CSFUNNEL_LAR = 0xC5ACCE55;

 

I'm still interested in hearing how I can use MCUxpresso to set registers to get more interesting analytics over SWO than just printing characters, which is my current setup.

0 Kudos
Reply
817 Views
jcallon
Contributor III
Oh, and I think I also needed to enable the ITM funnel for my port.
uint32_t *CSFUNNEL_CTRL = (uint32_t *)(TPIU_BASE + 0x4000);
*CSFUNNEL_CTRL |= 1; // Enable funnel for ITM (port 0)
0 Kudos
Reply