This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2340R5: Use the same pin for UART and SWD

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

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

  • Hello Alex, 

    I confirmed these things using an evaluation board. Using SysConfig, I set the CC2340R5's A1 and A2 pins (the pins for SWD) to UART and flashed the device via SWD. After that, when I tried to connect via SWD again, the SWD connection failed. It appears that a port configured for UART cannot be taken over as SWD when a debugger is connected.

    Regards, 

    Masa

  • Hello Masa,

    I downloaded the uart2echo_LP_EM_CC2340R5_freertos project from the TI SDK and changed the UART from use hardware XDS to none, then set the UART PinMux to DIO17 and DIO16. I was then able to both debug and flash the project, although I did not notice any activity on the UART line (from the UART driver I mean). 

    It may be that when the UART is active its blocking the SWD and when Idle the SWD can take over, I know this is similar to a case where I bound the mouse wheel to SWD and if you move it while debugging it breaks the session. 

    Thanks,
    Alex F

  • Hello Alex, 

    Thank you for replying.

    I am sure that UART is not active when I tried to connect debugger using SWD.

    If I want to do something like this, I shouldn't use Sysconfig to configure the UART??

    Regards, 

    Masa

  • Hello Masa,

    Yes I used Sysconfig in the test above to change the settings only.

    Thanks,
    Alex F

  • Hello Alex, 

    Then, It is the same situation as me.

    What do you think is the reason why things aren't going well for me?

    Regards,

    Masa

  • Hello Masa,

    Here is my modified UARTecho project which I used to test; I wanted to see if you could replicate the same behavior I see. In my test I fully disconnected the XDS from the LaucnhPad then I manually attached four wires (Gnd, 3.3 V, SWDIO, SWDCK) which I was able to debug/flash the device with, 

    uart2echo_LP_EM_CC2340R5_freertos_ticlang.zip

    Thanks,
    Alex F

  • Hello Alex, 

    Thank you.
    However, I was unable to import it correctly into my CCS.

    ###########################

    I'm getting the following error:

    【This project was created using a version of compiler that is not currently installed - TICLANG_4.0.4.LTS[Arm]】

    ###########################

    It might be because I'm using an older version of CCS.

    But I'm not in a position to use the latest version of CCS right now.

    My CCS version is 12.8.0.

    Could you please send me something that will work with this version?

    Regards, 

    Masa

  • Hello Masa,

    My CCS version is 12.7.1, but the SDK used here for the example is 9.12 F3 SDK. Which SDK do you have installed currently? You could also try to switch the SDK version of the project which may resolve your issue. 

    Thanks,
    Alex F

  • Hello Alex,

    Here is my SDK version「f3_sdk_8_20_00_119」

    How is it?

    Regards,

    Masa

  • Hello Masa,

    In the project properites in General we can change the Compiler version to 3.2.2.LTS:

    Then also in the General tab, switch to Products to switch the SDK:

    In the case of my project that I sent you, switch the compiler to 3.2.2 and to your downloaded SDK, if that does not work you could try to manually port my code (just the code in the uart2echo.c file, and the small changes I did in syscfg) into your project.

    Thanks,
    Alex F