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.

UART - Communication with two devices

Other Parts Discussed in Thread: CC2650

Hi,

I have been trying to implement communication with 2 different devices through UART. For that I tried to use the same UART to communicate with both but without great success, because one work fine, the other doesn't like it. So I was reading how to implement two UART, as I know that cc2650 only have 1, I know that I need to close one to start the other. The problem is that I need to change the board files to include another UART for different PINs. I did that and I notice that this variable "CC2650DK_5XD_UARTCOUNT" stay always 1 and not two as I need.

CC2650DK_5XD.h

/* UART Board */
#define Board_UART_RX                       IOID_4          /* P1.7  */
#define Board_UART_TX                       IOID_3          /* P1.9  */

#define Board_UART_RX1                      IOID_12          /* P1.7  */
#define Board_UART_TX1                      IOID_11          /* P1.9  */

#define Board_UART                  CC2650DK_5XD_UART0
#define Board_UART1                 CC2650DK_5XD_UART1
typedef enum CC2650DK_5XD_UARTName { CC2650DK_5XD_UART0 = 0, CC2650DK_5XD_UART1 = 0, CC2650DK_5XD_UARTCOUNT } CC2650DK_5XD_UARTName;

 

now CC2650DK_5XD.c

/* UART objects */
UARTCC26XX_Object uartCC26XXObjects[CC2650DK_5XD_UARTCOUNT];
unsigned char uartCC26XXRingBuffer[CC2650DK_5XD_UARTCOUNT][32];

/* UART hardware parameter structure, also used to assign UART pins */
const UARTCC26XX_HWAttrsV2 uartCC26XXHWAttrs[CC2650DK_5XD_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,
        .ringBufPtr     = uartCC26XXRingBuffer[0],
        .ringBufSize    = sizeof(uartCC26XXRingBuffer[0])
    },
    {
        .baseAddr       = UART0_BASE,
        .powerMngrId    = PowerCC26XX_PERIPH_UART0,
        .intNum         = INT_UART0_COMB,
        .intPriority    = ~0,
        .swiPriority    = 0,
        .txPin          = Board_UART_TX1,
        .rxPin          = Board_UART_RX1,
        .ctsPin         = PIN_UNASSIGNED,
        .rtsPin         = PIN_UNASSIGNED,
        .ringBufPtr     = uartCC26XXRingBuffer[0],
        .ringBufSize    = sizeof(uartCC26XXRingBuffer[0])
    }
};

/* UART configuration structure */
const UART_Config UART_config[] = {
    {
        .fxnTablePtr = &UARTCC26XX_fxnTable,
        .object      = &uartCC26XXObjects[0],
        .hwAttrs     = &uartCC26XXHWAttrs[0]
    },
    {
        .fxnTablePtr = &UARTCC26XX_fxnTable,
        .object      = &uartCC26XXObjects[0],
        .hwAttrs     = &uartCC26XXHWAttrs[0]
    },
    {NULL, NULL, NULL}
};

Do you know what I'm missing? When this is working with simple RTOS I will add it in a BLE program. Thank you.

Best Regards,

Miguel Vieira

  • There's UART emulator in Sensor Controller which I suggest you to use as second UART connection instead of changing pins between two UART pin defines.
  • Thank you for your reply,
    But I already tried to use the sensor controller but without success, I followed the example in sensor controller and used a device to see the characters in realTerm and nothing (probably I was doing something wrong). But apart from that, do you know what I need to change in my board files or a better example to test UART using the sensor controller?

    Best regards,
    Miguel Vieira
  • There is only one UART Emulator example in Sensor Controll and no others.
  • Hi Yikai,

    I tried the example from sensor controller but it doesn't work properly.

        // Start the UART emulator task
        scifExecuteTasksOnceNbl(BV(SCIF_UART_EMULATOR_TASK_ID));
    
        // Enable baud rate generation
        scifUartSetBaudRate(9600);
    
        // Enable RX
        scifUartSetRxEnableReqIdleCount(1);
        scifUartRxEnable(1);
    
        // Main loop
        while (1) {
    
            // Loop back any received characters
            while (scifUartGetRxFifoCount()) {
                scifUartTxPutChar((char) scifUartRxGetChar());
                PIN_setOutputValue(ledPinHandle, Board_LED0, !PIN_getOutputValue(Board_LED0));
            }
        }

    I add this code to my main task on UART echo example. Run it and nothing, can you tell me what i'm doing wrong? Thank you.

    Best Regards,

    Miguel Vieira