SWD

This introduction provides a general overview of the SWD debugging system.

Using SWD Debug Interface

Users can use SWD debugging with Keil or Jlink Commander.

SWD Hardware

SWD is a hardware interface standard developed by ARM for debugging and programming embedded systems. Compared to the traditional JTAG interface, SWD offers fewer pins, higher performance, and lower power consumption.

MCUConfig Tool Settings

P1_0 and P1_1 pins are set to SWDIO and SWCLK, respectively. Therefore, avoid using P1_0 and P1_1 pins in the MCUConfig Tool.

SWD with Keil

Using SWD with Keil μVision is a straightforward process that involves setting up your hardware and configuring the Keil debugging environment. Here’s a step-by-step guide to help you through the process.

Set the Debug Interface

Install the appropriate Jlink driver and then select the corresponding one in Debug Tab of ‘Options for Target…’. We need to choose ‘Jlink / J-trace Cortex’ for RTL87x3E. Then, Disable ‘Load Application at Startup’ which would reset the MCU.

Disable the Target Download before Debugging

By default, Keil will download the image through jlink when it starts debugging, so you need to disable the ‘Update Target before Debugging’ option. This option is in the Utilities Tab of ‘Options for Target…’.

Disable Watchdog and DLPS before Build

The purpose of disabling the watchdog is to not reset the MCU when it is halted by SWD. The way to disable the watchdog is as follows.

void system_init(void)
{
	wdg_disable();
	...
}

Make sure the MCU is not in the DLPS state. The way to disable DLPS is as follows.

int main(void)
{
	...
	app_cfg_init();
	...
	app_cfg_const.enable_dlps = 0;
	...
	app_dlps_init();
	...
}

Start a Debug Session during Running

  1. Click the ‘Debug’ button to start a Keil debugging session in Keil main window and MCU will be halted.

  1. Input the load command as below in the command window.

  1. Click the run button and MCU will be halted at the breakpoint.

If there is a pop-up window that mentions that it cannot find ‘SW device’, please reset the MCU and go back to ‘Cortex Jlink/Jtrace Target Driver Setup’ and follow the steps in section 3.2 to check ‘SW device’ information, which means Keil scanned and found ‘SW device’.

Start a Debug from Main Function

For the sake of capturing the MCU before running over the main function, we need to add a delay before the main function. We can add it in system_init of system_rtl8763.c. After pressing the reset key, you need to click Debug to start the simulation as soon as possible. Too fast and it will be too late to identify Jlink, too slow and it will run out of the main function.

  1. Reset the MCU and click the ‘Debug’ button to make the MCU halt before main.

  2. Input the command ‘LOAD %L INCREMENTAL’ in the command window.

  3. Set a breakpoint at the main and click the run button.

Jlink download is not supported, so the modified code needs to be recompiled and returned before debugging. During debugging, the ‘RESET’ button of Keil is not available. Please press the hardware reset on the EVB to start debugging from scratch.

Download with Keil

  1. Do Set the Debug Interface and Set the Configuration for Jlink.

  2. Copy RTL87x3E_FLASH.FLM in sdk\tool\flash to Keil root directory Keil\ARM\Flash and load the RTL87x3E_FLASH.FLM file as below figure.

  1. Download bin with Keil.