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.

CC1310: TI-RTOS problem

Other Parts Discussed in Thread: CC1310

Hi,

I ask you some questions.

1. Can I change uart pins from default configuration(DIO2: Rx, DIO3: Tx)?

2. Where is the SPI, I2C examples in TI-RTOS?

3. Can I use a pin for dual purpose? For example, in some case, for UART purpose, but in other case, used for General GPIO purpose.

Can I configure pin like this?

Best regards.

MF.

  • 1. Yes.
    2. You can find driver examples at dev.ti.com/.../
    3. Yes
  • Yes, as long as you don't want to use the serial bootloader.

    CCS -> Resource Explorer

    Yes - just close it for one purpose and open it for the other when you want to change it. Remember to use appropriate locking primitives if you want a smooth handover rather than polling for open failure.
  • Thanks, Yikai and Michael Moon.
    But I am not sure for your good advice.
    Are there any such tutorials or guide(1,3)?

  • Have you read section 11 in www.ti.com/.../swcu117g.pdf Pin mapping is also shown in the examples YK linked to.
  • Thanks, Michael Moon.

    I implemented 1 problem as your advice.

    I close pin before open it with new configuration, but ...

    But in the 3rd problem, what are the appropriate locking primitives?

    Here is my code snippet. ( in uartecho.c )

    PIN_Config ledPinTable[] = {
        IOID_25 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
        PIN_TERMINATE
    };
    
    PIN_Config uartPinTable[] = {
        IOID_25 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL,
        PIN_TERMINATE
    };
    
    static PIN_Handle ledPinHandle;
    static PIN_State ledPinState;
    static int repeat = 5;
    
    void *mainThread(void *arg0)
    {
    //    char        input;
        const char  echoPrompt[] = "Echoing characters:\r\n";
        UART_Handle uart;
        UART_Params uartParams;
    
        /* Call driver init functions */
    //    GPIO_init();
        UART_init();
    
        /* Turn on user LED */
    //    GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);
    
        /* Create a UART with data processing off. */
        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;
    
        uart = UART_open(Board_UART0, &uartParams);
    
        if (uart == NULL) {
            /* UART_open() failed */
            while (1);
        }
        UART_write(uart, echoPrompt, sizeof(echoPrompt));
    
    
        int count = 0;
    
        /* Loop forever echoing */
        int i;
        while (1) {
            if ( count%repeat == 0) {
                if ( (count/repeat)%2 == 0 ) {
                    UART_close(uart);
                    ledPinHandle = PIN_open(&ledPinState, ledPinTable);
                    if (!ledPinHandle)
                    {
                        break;
                        //System_abort("Error initializing board 3.3V domain pins\n");
                    }
                } else {
                    PIN_close(ledPinHandle);
                    if (PIN_init(uartPinTable) != PIN_SUCCESS) {
                        break;
                        //System_abort("Error with PIN_init\n");
                    }
                    UART_init();
                    uart = UART_open(Board_UART0, &uartParams);
                }
            } else {
                if ( (count/repeat)%2 == 0 ) {
                    PIN_setOutputValue(ledPinHandle, IOID_25,!PIN_getOutputValue(IOID_25));
                } else {
                    UART_write(uart, echoPrompt, sizeof(echoPrompt));
                }
            }
    
            for ( i = 0 ; i < 1000000 ; i ++ );
            count++;
        }
    }
    

  • With everything in one thread you don't need any.

    Locking primitives are needed when you have separate threads that both want access to a shared resource - use a semaphore or something so they can't both use it at the same time and break things
  • Hi,

    I would implement it a bit different. The following instructions refer to the board support file (BSF). The BSFs contain configuration structures for every driver. Example: CC1310DK_7XD.c, CC1310_LAUNCHXL.c, ...

    Set the default level that you want to be the shared pin(s) in the BSF's BoardGpioInitTable.

    #define SHARED_UART_TX_PIN    IOID_XXX
    
    const PIN_Config BoardGpioInitTable[] = {
    
        Board_DK_LED1    | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW   | PIN_PUSHPULL | PIN_DRVSTR_MAX,     /* LED initially off               */
        /* ... */
        SHARED_UART_TX_PIN | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH   | PIN_PUSHPULL,                     /* Shared UART TX pin at inactive level   */
        PIN_TERMINATE                                                                               /* Terminate list                  */
    };

    Add the pin(s) to the UART configuration object in the BSF:

    const UARTCC26XX_HWAttrsV2 uartCC26XXHWAttrs[CC1310DK_7XD_UARTCOUNT] = {
    {
    
    /*... */
    .txPin = SHARED_UART_TX_PIN,
    .rxPin = Board_UART_RX,
    .ctsPin = PIN_UNASSIGNED,
    .rtsPin = PIN_UNASSIGNED,
    /* ... */
    }
    };

    You may re-use the same pin in other driver configuration structures, for example the SPI driver. In your application, you must create a pin table for this pin when you want to use it with the PIN driver. There are short cuts without doing this, but I would not not recommend it if you don't know what is going on.

    PIN_Config pinTable[] =
    {
        SHARED_UART_TX_PIN | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW   | PIN_PUSHPULL,
        PIN_TERMINATE
    };

    In your application, you can only open either a PIN driver instance or an UART driver instance at a time. If you open the UART driver while the PIN driver has acquired this pin, then you will most likely (hopefully) get an error and XXX_open() will return a NULL handle. The same happens the other way around.

  • Thanks, Michael and Richard.
    Your friendly assistance makes my example well-working.
    Best regards.
    MF