Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob

EZ-PD™ PMG1 MCU: Debugging USB PD projects using UART debug logs instead of using breakpoints in debugger mode - KBA238646

EZ-PD™ PMG1 MCU: Debugging USB PD projects using UART debug logs instead of using breakpoints in debugger mode - KBA238646

Infineon_Team
Employee
Employee
50 replies posted 25 likes received 25 replies posted

Problem:

Issues with the use of breakpoints in the Debugger mode for USB PD projects such as USB PD sink, USB PD sink CAPSENSE™, USB PD DRP, and USB PD DRP EPR

Adding a breakpoint in any of the USB PD project and pressing the Resume play button during a debug session may result in an issue where the PMG1 device does not enter the PD contract.

For a USB PD project, VBUS can go up to 20 V. Using the CC lines, the sink needs to negotiate a PD contract with the source. These PD negotiations are time-critical and have a response time of milliseconds.

When a breakpoint is added to the PD sink project, the CPU stops at the breakpoint. If the breakpoint is at a location that can prevent the response to PD messages, the source sends a hard reset message to the sink, resulting in VBUS going from 5 V to 0 V, as shown in Figure 1 and Figure 2.

Infineon_Team_0-1695982979251.png

Figure 1  USB PD packets when “Resume” play button is pressed

Infineon_Team_1-1695983021495.png

Figure 2 VBUS voltage graph when “Resume” button is pressed

Solution:

Use UART debug logs

UART stands for Universal Asynchronous Receiver Transmitter. It is a simple two-wire protocol for exchanging serial data.

As UART uses only two pins (TX and RX), it can be used for debugging, like adding print statements that can be displayed on the UART port.

To see the UART data, use a serial console such as Teraterm or Putty.

Pre-requisites to use UART in the code example:

  1. Add UART peripheral in the Device Configurator.
Infineon_Team_2-1695983290127.png

 

Figure 3  UART configuration in Device Configurator
  1. Add the UART initialization code block in main.c after the cybsp_init() function.

    /* Configure and enable the UART peripheral */

    initstatus = Cy_SCB_UART_Init(CYBSP_UART_HW, &CYBSP_UART_config, &CYBSP_UART_context);

    /* Initialization failed. Halt the program */

    if(initstatus!=CY_SCB_UART_SUCCESS)

    {

        CY_ASSERT(CY_ASSERT_FAILED);

    }

    Cy_SCB_UART_Enable(CYBSP_UART_HW);

 

  1. Use the Cy_SCB_UART_PutString function to print the debug-related information on the serial terminal port.

     Cy_SCB_UART_PutString(CYBSP_UART_HW, "**********************************\r\n");

     Cy_SCB_UART_PutString(CYBSP_UART_HW, "UART Debug logs \r\n");

     Cy_SCB_UART_PutString(CYBSP_UART_HW, "**********************************\r\n\n");

     Cy_SCB_UART_PutString(CYBSP_UART_HW, "Debug log 1: Functionality executed\r\n");

     Cy_SCB_UART_PutString(CYBSP_UART_HW, "Debug log 2: Functionality fail\r\n");

Infineon_Team_3-1695983343149.png

Figure 4  Serial console output

For more details on how to use UART for the PMG1 series of devices, see code example UART echo.

0 Likes
91 Views
Contributors