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.

Compiler/CC3220SF-LAUNCHXL: Uart_open() fail

Part Number: CC3220SF-LAUNCHXL
Other Parts Discussed in Thread: CC3220SF

Tool/software: TI C/C++ Compiler

Playing for the first time with the TI C compiler, I'm trying to set up the UART like in some examples.
I also read the documentation about UART functions but I still have a problem.

When I call Uart_open() it returns NULL - hence it fails. The code is VERY simple and I'm running it on the CC3220SF-LAUNCHXL board.

int main(void)
{
    static UART_Handle uartHandle;

    PRCMCC3200MCUInit();
    Power_init();
    GPIO_init();

    UART_Params uartParams;

    UART_init();
    UART_Params_init(&uartParams);

    uartParams.writeDataMode    = UART_DATA_BINARY;
    uartParams.readDataMode     = UART_DATA_BINARY;
    uartParams.readReturnMode   = UART_RETURN_FULL;
    uartParams.readEcho         = UART_ECHO_OFF;
    uartParams.baudRate         = 115200;

    uartHandle = UART_open(Board_UART0, &uartParams);
    if (uartHandle == NULL) {
        GPIO_write(Board_GPIO_LED_RED, 1);
        for (;;) {}
    }
}
Here the configuration of the board:

typedef enum CC3220SF_LAUNCHXL_UARTName {
    CC3220SF_LAUNCHXL_UART0 = 0,
    CC3220SF_LAUNCHXL_UART1,

    CC3220SF_LAUNCHXL_UARTCOUNT
} CC3220SF_LAUNCHXL_UARTName;

#define Board_UART0               CC3220SF_LAUNCHXL_UART0

#include <ti/drivers/UART.h>
#include <ti/drivers/uart/UARTCC32XX.h>

UARTCC32XX_Object uartCC3220SObjects[CC3220SF_LAUNCHXL_UARTCOUNT];
unsigned char uartCC3220SRingBuffer[CC3220SF_LAUNCHXL_UARTCOUNT][32];

const UARTCC32XX_HWAttrsV1 uartCC3220SHWAttrs[CC3220SF_LAUNCHXL_UARTCOUNT] = {
    {
        .baseAddr = UARTA0_BASE,
        .intNum = INT_UARTA0,
        .intPriority = (~0),
        .flowControl = UARTCC32XX_FLOWCTRL_NONE,
        .ringBufPtr  = uartCC3220SRingBuffer[CC3220SF_LAUNCHXL_UART0],
        .ringBufSize = sizeof(uartCC3220SRingBuffer[CC3220SF_LAUNCHXL_UART0]),
        .rxPin = UARTCC32XX_PIN_57_UART0_RX,
        .txPin = UARTCC32XX_PIN_55_UART0_TX,
        .ctsPin = UARTCC32XX_PIN_UNASSIGNED,
        .rtsPin = UARTCC32XX_PIN_UNASSIGNED
    },
    {
        .baseAddr = UARTA1_BASE,
        .intNum = INT_UARTA1,
        .intPriority = (~0),
        .flowControl = UARTCC32XX_FLOWCTRL_NONE,
        .ringBufPtr  = uartCC3220SRingBuffer[CC3220SF_LAUNCHXL_UART1],
        .ringBufSize = sizeof(uartCC3220SRingBuffer[CC3220SF_LAUNCHXL_UART1]),
        .rxPin = UARTCC32XX_PIN_08_UART1_RX,
        .txPin = UARTCC32XX_PIN_07_UART1_TX,
        .ctsPin = UARTCC32XX_PIN_UNASSIGNED,
        .rtsPin = UARTCC32XX_PIN_UNASSIGNED
    }
};

const UART_Config UART_config[CC3220SF_LAUNCHXL_UARTCOUNT] = {
    {
        .fxnTablePtr = &UARTCC32XX_fxnTable,
        .object = &uartCC3220SObjects[CC3220SF_LAUNCHXL_UART0],
        .hwAttrs = &uartCC3220SHWAttrs[CC3220SF_LAUNCHXL_UART0]
    },
    {
        .fxnTablePtr = &UARTCC32XX_fxnTable,
        .object = &uartCC3220SObjects[CC3220SF_LAUNCHXL_UART1],
        .hwAttrs = &uartCC3220SHWAttrs[CC3220SF_LAUNCHXL_UART1]
    }
};

const uint_least8_t UART_count = CC3220SF_LAUNCHXL_UARTCOUNT;

Please, would you help me to understand why it fails?




  • At a glance it seems okay, but try running the (nortos) power_measurement example since it has the configuration your want.

    -Aaron
  • My code was derived exactly from the power_measurement example! And it works.
    But to deeper understand this new platform I tried to setup a new project from scratch, adding the code to configure the UART.

    Perhaps I forgot something?
  • Found the problem: it was the .cmd file. Here the one generated by CCS:

    --retain=g_pfnVectors
    --retain=ulDebugHeader
    
    #define FLASH_BASE 0x01000800
    #define FLHDR_BASE 0x01000000
    
    MEMORY
    {
        /* Application uses internal RAM for program and data */
        FLASH_HDR	(RX)  : origin = 0x01000000, length = 0x7FF    /* 2 KB */
        FLASH_CODE  (RX)  : origin = 0x01000800, length = 0x0FF800 /* 1022KB */
        SRAM_DATA   (RWX) : origin = 0x20000000, length = 0x040000 /* 256KB */
    }
    
    SECTIONS
    {
        .dgbhdr     	  : > FLHDR_BASE
        .resetVecs            : > FLASH_BASE
        .init_array           : > FLASH_CODE
        .text                 : > FLASH_CODE
        .const                : > FLASH_CODE
        .cinit                : > FLASH_CODE
        .pinit                : > FLASH_CODE
        .ramvecs              : > SRAM_DATA ALIGN(1024)
        .data                 : > SRAM_DATA
        .bss                  : > SRAM_DATA
        .sysmem               : > SRAM_DATA
        .stack                : > SRAM_DATA(HIGH)
    }
    
    

    and here the one of the example:

    --stack_size=0x1000
    --heap_size=0x8000
    
    #define SRAM_BASE   0x20000000
    #define FLASH_BASE  0x01000800
    
    MEMORY
    {
        /* Bootloader uses FLASH_HDR during initialization */
        FLASH_HDR (RX)  : origin = 0x01000000, length = 0x7FF      /* 2 KB */
        FLASH     (RX)  : origin = 0x01000800, length = 0x0FF800   /* 1022KB */
        SRAM      (RWX) : origin = 0x20000000, length = 0x00040000 /* 256KB */
    }
    
    SECTIONS
    {
        .dbghdr     : > FLASH_HDR
        .text       : > FLASH
        .TI.ramfunc : {} load=FLASH, run=SRAM, table(BINIT)
        .const      : > FLASH
        .cinit      : > FLASH
        .pinit      : > FLASH
        .init_array : > FLASH
    
        .data       : > SRAM
        .bss        : > SRAM
        .sysmem     : > SRAM
        .stack      : > SRAM(HIGH)
    
        .resetVecs  : > FLASH_BASE
        .ramVecs    : > SRAM_BASE, type=NOLOAD
    }
    

    They are quite different!
    What document I should read to understand how to write the correct cmd file?

  • Hi Mark,

    It's not expected to write your own usually. If you want to know where all of this comes from you will need to read the cc3220 TRM, and take a look at this: processors.wiki.ti.com/.../Linker_Command_File_Primer

    -Aaron
  • I will.
    Because the command files are so different between the dev board and the "plain" MCU I'm afraid about my own board based upon CC3220SF