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.

Changing UART port pin at runtime (CC1310)

Other Parts Discussed in Thread: CC1310

Hello,

We have a CC1310 with the UART working nicely. I can see the RX & TX being set up with the following code:

/*

* ============================= UART begin ===================================

*/

/* Place into subsections to allow the TI linker to remove items properly */

#if defined(__TI_COMPILER_VERSION__)

#pragma DATA_SECTION(UART_config, ".const:UART_config")

#pragma DATA_SECTION(uartCC26XXHWAttrs, ".const:uartCC26XXHWAttrs")

#endif




/* Include drivers */

#include <ti/drivers/UART.h>

#include <ti/drivers/uart/UARTCC26XX.h>




/* UART objects */

UARTCC26XX_Object uartCC26XXObjects[CC1310_LAUNCHXL_UARTCOUNT];




/* UART hardware parameter structure, also used to assign UART pins */

const UARTCC26XX_HWAttrsV1 uartCC26XXHWAttrs[CC1310_LAUNCHXL_UARTCOUNT] = {

{

.baseAddr = UART0_BASE,

.powerMngrId = PowerCC26XX_PERIPH_UART0,

.intNum = INT_UART0_COMB,

.intPriority = ~0,

.swiPriority = 0,

.txPin = Board_UART_TX,

.rxPin = Board_UART_RX,

.ctsPin = PIN_UNASSIGNED,

.rtsPin = PIN_UNASSIGNED

}

};

/* UART configuration structure */

const UART_Config UART_config[] = {

{

.fxnTablePtr = &UARTCC26XX_fxnTable,

.object = &uartCC26XXObjects[0],

.hwAttrs = &uartCC26XXHWAttrs[0]

},

{NULL, NULL, NULL}

};

I understand that the CC1310 only has 1 UART.

My question is it possible to change TX pin on runtime?

For example, once powered on, I need the CC1310 to transmit a few commands on IOID_26. After those commands are sent, I want to change the TX pin to IOID_30. The TX pin will remain on IOID_30 till reset or till power is lost. Is it possible to achieve this operation? Please let me know.

Thanks in advance,

Jayson

  • I believe this can be done, but you'll have to cheat a little to get there.

    1) remove the "const" from the uartCC26XXHWAttrs declaration so that you can overwrite the .txPin field within the hwAttrs.
    2) Call UART_close() after you're finished using the initial txPin configuration.
    3) Add something like this in your code:
    uartCC26XXHWAttrs[0].txPin = IOID30;
    4) Re-open the UART instance.

    Alan
  • Easy enough. I tried this, but program execution fails as soon as I remove const from uartCC26XXHWAttrs declaration.

    To elaborate, the only code change is to remove const from uartCC26XXHWAttrs declaration. Compile is successful. When I press the debug button, I never get to main. All debug options are grayed out in CCS. The only options available is stop debugging, and reset. Placing the const keyword, I get to main no problem.

    Any other ideas?

  • Hmm. Try removing "const" from this line too:

    const UART_Config UART_config[] = {

    Alan
  • Alan,

    I get the same result. The program fails to get into main in debug. Only options are reset and terminate (debugging). I can only get into main if const is there for:

    const UARTCC26XX_HWAttrsV1 uartCC26XXHWAttrs
    const UART_Config UART_config
  • Try removing these lines:

    #if defined(__TI_COMPILER_VERSION__)
    #pragma DATA_SECTION(UART_config, ".const:UART_config")
    #pragma DATA_SECTION(uartCC26XXHWAttrs, ".const:uartCC26XXHWAttrs")
    #endif

    They are sending a conflicting message to the linker.