CC2340R5: Use the same pin for UART and SWD

Part Number: CC2340R5
Other Parts Discussed in Thread: LP-XDS110ET

Tool/software:

Hello E2E

I'm having trouble because the CC2340R5 has fewer pins than I need.

Can we use the A1 and A2 pins for both UART and SWD?

I would like the A1 and A2 pins to be set to UART normally, and then automatically taken over as SWD when a debugger (LP-XDS110ET) is connected.

Please let me know what I should be careful of in this case.

Regards, 

Masa

  • Hello Masa,

    Yes this should be possible, however when you are debugging the device you will need to make sure the UART is not used (or anything else you have attached to the A1/A2 pins) as this would stop the debug session (or mess up flashing).

    Thanks,
    Alex F 

  • Hello Alex, 

    Thank you for quick replying.

    I understand well, but I want to know more about how it works electrically.

    Even though the A1 and A2 pins of the CC2340R5 are configured as UART, how does it know that a debugger is connected and decide to start SWD?

    Also, how can I return to UART settings after using SWD?

    Regards, 

    Masa

  • Hello,

    I believe that after board_init is called we can use the pins as needed, from the TRM if we want to use the SWD to flash the device we need to do a POR. 

    Some information from the TRM:

    "After a power-on reset (POR), the target device configures the SWD pins in SWD mode with an internal pullup resistor enabled on the SWDIO line and an internal pulldown resistor enabled on the SWCLK line. If the device configuration has not permanently disabled all SWD access, then the SWD interface is enabled during the boot process and a debug probe can be connected to the DEBUGSS." 

    "Bootcode can disable the SWD interface in DEBUGSS, freeing the IOs to be used for general-purpose IO functionality. Once the boot code disables SWD functionality, SWD functionality cannot be re-enabled other than by triggering a POR. A POR automatically re-enables the SWD functionality and puts the SWD pins into SWD mode with pullup/pulldown resistors enabled. To regain debug access to a device, hold the device in a reset state with the RSTN pin during a POR. This prevents the boot code from starting and lets the debug probe gain access to the device"

    CC23xx SimpleLink Wireless MCU (Rev. A)

    Thanks,
    Alex F

  • Hello Alex, 

    Thank you for replying.

    But your additional comments made me confused, so let me confirm again.

    The answer to my first question is still unclear.

    First of all, could you please clarify whether the answer to my first question is POSSIBLE or INPOSSIBLE?

    ↓ MY FIRST QUESTION ↓

    「Can we use the A1 and A2 pins for both UART and SWD? I would like the A1 and A2 pins to be set to UART normally, and then automatically taken over as SWD when a debugger (LP-XDS110ET) is connected.」

    Regards, Masa.

  • Hello Masa,

    Can we use the A1 and A2 pins for both UART and SWD?

    Yes you can use the A1 and A2 pins (SWDIO, SWDCK) as UART, and SWD:

    To my current knowledge how this works is we are basically multiplexing the pins, and the XDS110 takes charge of the pins when a Debug connection is established (through JTAG SWD mode, somehow the device can tell when this is accessed or not). 

    Thanks,
    Alex F