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: LAUNCHXL-CC13-90 I2C data transmission

Part Number: CC1310
Other Parts Discussed in Thread: TMP116, SYSBIOS

Tool/software:

Hello,
I was working on a project in which I had to transmit the I2C data received to another board using Easylink API.
I first worked on the example I2C Temperature sensor code and Easylink Rx/Tx Codes given in resource monitor and made some changes.
I2C code is working well ... But I'm finding difficulty in combining both I2C and Tx/Rx codes, Can anyone help me with that...
I have attached the codes that I have modified below.

This is the I2C code i wrote to obtain 12 sensor data's From another MCU and the Code is working well...I have named the sensor data as a,b,c,d,e,f,g,h,i,j,k,l.

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

#include <stdint.h>
#include <stddef.h>
#include <unistd.h>

/* Driver Header files */
#include <ti/drivers/GPIO.h>
#include <ti/drivers/I2C.h>
#include <ti/display/Display.h>

/* Example/Board Header files */
#include "Board.h"
#include "ti/drivers/NVS.h"

#define TASKSTACKSIZE       640
#define ArduinoAddr         0xAF;

static Display_Handle display;

/*
 *  ======== mainThread ========
 */
void *mainThread(void *arg0)
{
    uint16_t a;
    uint16_t b;
    uint16_t c;
    uint16_t d;            
    uint16_t e;
    uint16_t f;
    uint16_t g;
    uint16_t h;
    uint16_t i;            
    uint16_t j;
    uint16_t k;
    uint16_t l;
    uint8_t         rxBuffer[24];
    I2C_Handle      i2c;
    I2C_Params      i2cParams;
    I2C_Transaction i2cTransaction;

    /* Call driver init functions */
    Display_init();
    GPIO_init();
    I2C_init();

    /* Configure the LED and if applicable, the TMP116_EN pin */
    GPIO_setConfig(Board_GPIO_LED0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
#ifdef Board_GPIO_TMP116_EN
    GPIO_setConfig(Board_GPIO_TMP116_EN, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_HIGH);
    /* 1.5 ms reset time for the TMP116 */
    sleep(1);
#endif

    /* Open the HOST display for output */
    display = Display_open(Display_Type_UART, NULL);
    if (display == NULL) {
        while (1);
    }

    /* Turn on user LED */
    GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);
    Display_printf(display, 0, 0, "Starting the i2c example.");

    /* Create I2C for usage */
    I2C_Params_init(&i2cParams);
    i2cParams.bitRate = I2C_400kHz;
    i2c = I2C_open(Board_I2C_TMP, &i2cParams);
    if (i2c == NULL) {
        Display_printf(display, 0, 0, "Error Initializing I2C\n");
        while (1);
    }
    else {
        Display_printf(display, 0, 0, "I2C Initialized!\n");
    }

    /* Common I2C transaction setup */
    i2cTransaction.writeBuf   = 0;
    i2cTransaction.writeCount = NULL;
    i2cTransaction.readBuf    = rxBuffer;
    i2cTransaction.readCount  = 24;
    i2cTransaction.slaveAddress = ArduinoAddr;
    if (!I2C_transfer(i2c, &i2cTransaction)) {
         /* Could not resolve a sensor, error */
        Display_printf(display, 0, 0, "Error. No Arduino found!");
        while(1);
        }
        while(1){
        if (I2C_transfer(i2c, &i2cTransaction)) {
            a= (rxBuffer[0] << 8) | (rxBuffer[1]);
            b = (rxBuffer[2] << 8) | (rxBuffer[3]);
            c = (rxBuffer[4] << 8) | (rxBuffer[5]);            
            d = (rxBuffer[6] << 8) | (rxBuffer[7]);
            e = (rxBuffer[8] << 8) | (rxBuffer[9]);
            f = (rxBuffer[10] << 8) | (rxBuffer[11]);
            g = (rxBuffer[12] << 8) | (rxBuffer[13]);
            h = (rxBuffer[14] << 8) | (rxBuffer[15]);
            i = (rxBuffer[16] << 8) | (rxBuffer[17]);
            j = (rxBuffer[18] << 8) | (rxBuffer[19]);
            k = (rxBuffer[20] << 8) | (rxBuffer[21]);
            l = (rxBuffer[22] << 8) | (rxBuffer[23]);    
            Display_printf(display, 0, 0, "%d %d %d %d %d %d %d %d %d %d %d %d",a, b, c, d,e, f, g, h,i, j, k, l );
        }
        else {
            Display_printf(display, 0, 0, "I2C Bus fault.");
        }
        }
    return (NULL);
}

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

This code I wrote with help of the Easylink Tx/Rx example given in resource monitor and tried to transmit I2C data  but the expected output is not obtained...
Can anyone point out if there is any mistake done here..


#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>

/* XDCtools Header files */
#include <xdc/std.h>
#include <xdc/runtime/Assert.h>
#include <xdc/runtime/Error.h>
#include <xdc/runtime/System.h>

/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/knl/Semaphore.h>
#include <ti/sysbios/knl/Clock.h>

/* TI-RTOS Header files */
#include <ti/drivers/PIN.h>
#include <ti/drivers/I2C.h>
#include <ti/display/Display.h>

/* Board Header files */
#include "Board.h"
#include <ti/drivers/ADC.h>

/* EasyLink API Header files */
#include "easylink/EasyLink.h"
#include <ti/drivers/pin/PINCC26XX.h>

/* Application header files */
#include "smartrf_settings/smartrf_settings.h"

#include <ti/devices/cc13x0/driverlib/ioc.h>

#define RFEASYLINKTX_ASYNC
#define RFEASYLINKTX_TASK_STACK_SIZE    1024
#define RFEASYLINKTX_TASK_PRIORITY      2
#define RFEASYLINKTX_BURST_SIZE         10
#define RFEASYLINKTXPAYLOAD_LENGTH      30

#define I2C_TASK_STACK_SIZE             1024
#define I2C_TASK_PRIORITY               1

#define ArduinoAddr 0xAF

Task_Struct txTask;    /* not static so you can see in ROV */
static Task_Params txTaskParams;
static uint8_t txTaskStack[RFEASYLINKTX_TASK_STACK_SIZE];

Task_Struct i2cTask;   /* not static so you can see in ROV */
static Task_Params i2cTaskParams;
static uint8_t i2cTaskStack[I2C_TASK_STACK_SIZE];

/* Pin driver handle */
static PIN_Handle pinHandle;
static PIN_State pinState;

static uint16_t receivedData[12]; // Array to store the received 16-bit data
static Semaphore_Handle i2cSemaphore;

PIN_Config pinTable[] = {
    Board_PIN_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    Board_PIN_LED2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    IOID_28 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    PIN_TERMINATE
};

#ifdef RFEASYLINKTX_ASYNC
static Semaphore_Handle txDoneSem;
#endif //RFEASYLINKTX_ASYNC

#ifdef RFEASYLINKTX_ASYNC
void txDoneCb(EasyLink_Status status)
{
    if (status == EasyLink_Status_Success) {
        /* Toggle LED1 to indicate TX */
        PIN_setOutputValue(pinHandle, Board_PIN_LED1,!PIN_getOutputValue(Board_PIN_LED1));
    }
    else if(status == EasyLink_Status_Aborted) {
        /* Toggle LED2 to indicate command aborted */
        PIN_setOutputValue(pinHandle, Board_PIN_LED2,!PIN_getOutputValue(Board_PIN_LED2));
    }
    else {
        /* Toggle LED1 and LED2 to indicate error */
        PIN_setOutputValue(pinHandle, Board_PIN_LED1,!PIN_getOutputValue(Board_PIN_LED1));
        PIN_setOutputValue(pinHandle, Board_PIN_LED2,!PIN_getOutputValue(Board_PIN_LED2));
    }

    Semaphore_post(txDoneSem);
}
#endif //RFEASYLINKTX_ASYNC

static void rfEasyLinkTxFnx(UArg arg0, UArg arg1)
{
    uint32_t absTime;
    uint8_t txBurstSize = 0;

#ifdef RFEASYLINKTX_ASYNC
    /* Create a semaphore for Async */
    Semaphore_Params params;
    Error_Block eb;

    /* Init params */
    Semaphore_Params_init(&params);
    Error_init(&eb);

    /* Create semaphore instance */
    txDoneSem = Semaphore_create(0, &params, &eb);
    if(txDoneSem == NULL) {
        System_abort("Semaphore creation failed");
    }
#endif //TX_ASYNC

    // Initialize the EasyLink parameters to their default values
    EasyLink_Params easyLink_params;
    EasyLink_Params_init(&easyLink_params);

    /*
     * Initialize EasyLink with the settings found in easylink_config.h
     * Modify EASYLINK_PARAM_CONFIG in easylink_config.h to change the default
     * PHY
     */
    if(EasyLink_init(&easyLink_params) != EasyLink_Status_Success) {
        System_abort("EasyLink_init failed");
    }

    while(1) {
        Semaphore_pend(i2cSemaphore, BIOS_WAIT_FOREVER);

        EasyLink_TxPacket txPacket = { {0}, 0, 0, {0} };
        // uint8_t* p = txPacket.payload;

        // Directly assign the received 16-bit variables to the payload
        txPacket.payload[0] = receivedData[0] ;
        txPacket.payload[1] = receivedData[1] ;
        txPacket.payload[2] = receivedData[2] ;
        txPacket.payload[3] = receivedData[3] ;
        txPacket.payload[4] = receivedData[4] ;
        txPacket.payload[5] = receivedData[5] ;
        txPacket.payload[6] = receivedData[6] ;
        txPacket.payload[7] = receivedData[7] ;
        txPacket.payload[8] = receivedData[8] ;
        txPacket.payload[9] = receivedData[9] ;
        txPacket.payload[10] = receivedData[10];
        txPacket.payload[11] = receivedData[11];
       

        txPacket.len = 12;
        txPacket.dstAddr[0] = 0xaa;

        if (EasyLink_getAbsTime(&absTime) != EasyLink_Status_Success) {
            // Problem getting absolute time
        }
        if(txBurstSize++ >= RFEASYLINKTX_BURST_SIZE) {
            txPacket.absTime = absTime + EasyLink_ms_To_RadioTime(1000);
            txBurstSize = 0;
        } else {
            txPacket.absTime = absTime + EasyLink_ms_To_RadioTime(10);
        }

#ifdef RFEASYLINKTX_ASYNC
        EasyLink_transmitAsync(&txPacket, txDoneCb);
        if(Semaphore_pend(txDoneSem, (30000 / Clock_tickPeriod)) == FALSE) {
            if(EasyLink_abort() == EasyLink_Status_Success) {
                Semaphore_pend(txDoneSem, BIOS_WAIT_FOREVER);
            }
        }
#else
        EasyLink_Status result = EasyLink_transmit(&txPacket);
        if (result == EasyLink_Status_Success) {
            PIN_setOutputValue(pinHandle, Board_PIN_LED1,!PIN_getOutputValue(Board_PIN_LED1));
        } else {
            PIN_setOutputValue(pinHandle, Board_PIN_LED1,!PIN_getOutputValue(Board_PIN_LED1));
            PIN_setOutputValue(pinHandle, Board_PIN_LED2,!PIN_getOutputValue(Board_PIN_LED2));
        }
#endif //RFEASYLINKTX_ASYNC
    }
}

static void i2cTaskFnx(UArg arg0, UArg arg1)
{
    I2C_Handle i2c;
    I2C_Params i2cParams;
    I2C_Transaction i2cTransaction;
    uint8_t rxBuffer[24];

    // Initialize I2C
    I2C_Params_init(&i2cParams);
    i2cParams.bitRate = I2C_400kHz;
    i2c = I2C_open(Board_I2C_TMP, &i2cParams);
    if (i2c == NULL) {
        System_abort("I2C_init failed");
    }

    /* Common I2C transaction setup */
    i2cTransaction.writeBuf   = 0;
    i2cTransaction.writeCount = 0;
    i2cTransaction.readBuf    = rxBuffer;
    i2cTransaction.readCount  = 24;
    i2cTransaction.slaveAddress = ArduinoAddr;

    while(1) {
        if (I2C_transfer(i2c, &i2cTransaction)) {
            /*
             * Extract 16-bit values from the received data
             */
            receivedData[0] = (rxBuffer[0] << 8) | rxBuffer[1];
            receivedData[1] = (rxBuffer[2] << 8) | rxBuffer[3];
            receivedData[2] = (rxBuffer[4] << 8) | rxBuffer[5];
            receivedData[3] = (rxBuffer[6] << 8) | rxBuffer[7];
            receivedData[4] = (rxBuffer[8] << 8) | rxBuffer[9];
            receivedData[5] = (rxBuffer[10] << 8) | rxBuffer[11];
            receivedData[6] = (rxBuffer[12] << 8) | rxBuffer[13];
            receivedData[7] = (rxBuffer[14] << 8) | rxBuffer[15];
            receivedData[8] = (rxBuffer[16] << 8) | rxBuffer[17];
            receivedData[9] = (rxBuffer[18] << 8) | rxBuffer[19];
            receivedData[10] = (rxBuffer[20] << 8) | rxBuffer[21];
            receivedData[11] = (rxBuffer[22] << 8) | rxBuffer[23];

            // Signal the TX task to transmit the received data
            Semaphore_post(i2cSemaphore);
        } else {
            System_printf("I2C Bus fault.\n");
        }

        // Sleep for a while before the next I2C read
        Task_sleep(1000000 / Clock_tickPeriod);
    }
}

void txTask_init(PIN_Handle inPinHandle) {
    pinHandle = inPinHandle;

    Task_Params_init(&txTaskParams);
    txTaskParams.stackSize = RFEASYLINKTX_TASK_STACK_SIZE;
    txTaskParams.priority = RFEASYLINKTX_TASK_PRIORITY;
    txTaskParams.stack = &txTaskStack;
    txTaskParams.arg0 = (UInt)1000000;

    Task_construct(&txTask, rfEasyLinkTxFnx, &txTaskParams, NULL);
}

void i2cTask_init() {
    Task_Params_init(&i2cTaskParams);
    i2cTaskParams.stackSize = I2C_TASK_STACK_SIZE;
    i2cTaskParams.priority = I2C_TASK_PRIORITY;
    i2cTaskParams.stack = &i2cTaskStack;
    i2cTaskParams.arg0 = (UInt)1000000;

    Task_construct(&i2cTask, i2cTaskFnx, &i2cTaskParams, NULL);
}

int main(void)
{
    Board_initGeneral();
    IOCPortConfigureSet(IOID_29, IOC_PORT_RFC_GPO0, IOC_IOMODE_NORMAL);
    IOCPortConfigureSet(IOID_30, IOC_PORT_RFC_GPO1, IOC_IOMODE_NORMAL);

    pinHandle = PIN_open(&pinState, pinTable);
    Assert_isTrue(pinHandle != NULL, NULL);

    PIN_setOutputValue(pinHandle, Board_PIN_LED1, 0);
    PIN_setOutputValue(pinHandle, Board_PIN_LED2, 0);

    /* Create a semaphore for I2C synchronization */
    Semaphore_Params semParams;
    Semaphore_Params_init(&semParams);
    i2cSemaphore = Semaphore_create(0, &semParams, NULL);

    txTask_init(pinHandle);
    i2cTask_init();

    BIOS_start();

    return (0);
}

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------



Thank You.

  • Hi,

    I don't have the bandwidth to review your code. However I will try to give you some pointers on how to debug your issue.

    Did you see our debugging guide for I2C?

    https://dev.ti.com/tirex/content/simplelink_cc13x0_sdk_4_20_02_07/docs/proprietary-rf/proprietary-rf-users-guide/proprietary-rf-guide/debugging-index.html#debugging-guide-for-serial-interfaces

    Cheers,

    Marie H

  • Hello,
    Is there any updates?

    Thanks

  • /*
     *  ======== FSC_CAN_DATA_TX.c ========
     */
     /* Standard C Libraries */
    #include <stdlib.h>
    #include <stdint.h>
    #include <stddef.h>
    #include <unistd.h>

    /* XDCtools Header files */
    #include <xdc/std.h>
    #include <xdc/runtime/Assert.h>
    #include <xdc/runtime/Error.h>
    #include <xdc/runtime/System.h>

    /* BIOS Header files */
    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Task.h>
    #include <ti/sysbios/knl/Semaphore.h>
    #include <ti/sysbios/knl/Clock.h>

    /* TI-RTOS Header files */
    #include <ti/drivers/PIN.h>

    /* Board Header files */
    #include "Board.h"
    #include "ti/drivers/NVS.h"

    /* EasyLink API Header files */
    #include "easylink/EasyLink.h"

    /* Application header files */
    #include "smartrf_settings/smartrf_settings.h"

    /* Driver Header files */
    #include <ti/drivers/GPIO.h>
    #include <ti/drivers/I2C.h>
    #include <ti/display/Display.h>

    /* Undefine to not use async mode */
    #define RFEASYLINKTX_ASYNC

    #define RFEASYLINKTX_TASK_STACK_SIZE    1024
    #define RFEASYLINKTX_TASK_PRIORITY      2

    #define RFEASYLINKTX_BURST_SIZE         10
    #define RFEASYLINKTXPAYLOAD_LENGTH      30
    #define I2C_TASK_STACK_SIZE             1024
    #define I2C_TASK_PRIORITY               1

    #define ArduinoAddr         0xAF;

    Task_Struct txTask, i2cTask;    /* not static so you can see in ROV */
    static Task_Params txTaskParams, i2cTaskParams;
    static uint8_t txTaskStack[RFEASYLINKTX_TASK_STACK_SIZE];
    static uint8_t i2cTaskStack[I2C_TASK_STACK_SIZE];

    /* Pin driver handle */
    static PIN_Handle pinHandle;
    static PIN_State pinState;

    uint16_t a, b, c, d, e, f, g, h, i, j, k, l;
    uint8_t rxBuffer[24];

    PIN_Config pinTable[] = {
        Board_PIN_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
        Board_PIN_LED2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
        //Range extender config
        IOID_28 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
        PIN_TERMINATE
    };

    #ifdef RFEASYLINKTX_ASYNC
    static Semaphore_Handle txDoneSem;
    #endif //RFEASYLINKTX_ASYNC

    #ifdef RFEASYLINKTX_ASYNC
    void txDoneCb(EasyLink_Status status)
    {
        if (status == EasyLink_Status_Success) {
            /* Toggle LED1 to indicate TX */
            PIN_setOutputValue(pinHandle, Board_PIN_LED1, !PIN_getOutputValue(Board_PIN_LED1));
        } else if (status == EasyLink_Status_Aborted) {
            /* Toggle LED2 to indicate command aborted */
            PIN_setOutputValue(pinHandle, Board_PIN_LED2, !PIN_getOutputValue(Board_PIN_LED2));
        } else {
            /* Toggle LED1 and LED2 to indicate error */
            PIN_setOutputValue(pinHandle, Board_PIN_LED1, !PIN_getOutputValue(Board_PIN_LED1));
            PIN_setOutputValue(pinHandle, Board_PIN_LED2, !PIN_getOutputValue(Board_PIN_LED2));
        }

        Semaphore_post(txDoneSem);
    }
    #endif //RFEASYLINKTX_ASYNC

    static void rfEasyLinkTxFnx(UArg arg0, UArg arg1)
    {
        uint8_t txBurstSize = 0;
        uint32_t absTime;

    #ifdef RFEASYLINKTX_ASYNC
        /* Create a semaphore for Async */
        Semaphore_Params params;
        Error_Block eb;

        /* Init params */
        Semaphore_Params_init(&params);
        Error_init(&eb);

        /* Create semaphore instance */
        txDoneSem = Semaphore_create(0, &params, &eb);
        if(txDoneSem == NULL)
        {
            System_abort("Semaphore creation failed");
        }

    #endif //TX_ASYNC

        // Initialize the EasyLink parameters to their default values
        EasyLink_Params easyLink_params;
        EasyLink_Params_init(&easyLink_params);

        /*
         * Initialize EasyLink with the settings found in easylink_config.h
         * Modify EASYLINK_PARAM_CONFIG in easylink_config.h to change the default
         * PHY
         */
        if(EasyLink_init(&easyLink_params) != EasyLink_Status_Success)
        {
            System_abort("EasyLink_init failed");
        }

        /*
         * If you wish to use a frequency other than the default, use
         * the following API:
         * EasyLink_setFrequency(868000000);
         */

        while(1) {
            EasyLink_TxPacket txPacket =  { {0}, 0, 0, {0} };

            /* Create packet with incrementing sequence number and random payload */
            txPacket.payload[0] = a;
            txPacket.payload[1] = b ;
            txPacket.payload[2] = c ;
            txPacket.payload[3] = d ;
            txPacket.payload[4] = e ;
            txPacket.payload[5] = f ;
            txPacket.payload[6] = g ;
            txPacket.payload[7] = h ;
            txPacket.payload[8] = i ;
            txPacket.payload[9] = j ;
            txPacket.payload[10] = k;
            txPacket.payload[11] = l;

            txPacket.len = RFEASYLINKTXPAYLOAD_LENGTH;

            /*
             * Address filtering is enabled by default on the Rx device with the
             * an address of 0xAA. This device must set the dstAddr accordingly.
             */
            txPacket.dstAddr[0] = 0xaa;

            /* Add a Tx delay for > 500ms, so that the abort kicks in and breaks the burst */
            if(EasyLink_getAbsTime(&absTime) != EasyLink_Status_Success)
            {
                // Problem getting absolute time
            }
            if(txBurstSize++ >= RFEASYLINKTX_BURST_SIZE)
            {
              /* Set Tx absolute time to current time + 1s */
              txPacket.absTime = absTime + EasyLink_ms_To_RadioTime(1000);
              txBurstSize = 0;
            }
            /* Else set the next packet in burst to Tx in 100ms */
            else
            {
              /* Set Tx absolute time to current time + 100ms */
              txPacket.absTime = absTime + EasyLink_ms_To_RadioTime(10);
            }

    #ifdef RFEASYLINKTX_ASYNC
            EasyLink_transmitAsync(&txPacket, txDoneCb);
            /* Wait 300ms for Tx to complete */
            if(Semaphore_pend(txDoneSem, (30000 / Clock_tickPeriod)) == FALSE)
            {
                /* TX timed out, abort */
                if(EasyLink_abort() == EasyLink_Status_Success)
                {
                    /*
                     * Abort will cause the txDoneCb to be called and the txDoneSem
                     * to be released, so we must consume the txDoneSem
                     */
                   Semaphore_pend(txDoneSem, BIOS_WAIT_FOREVER);
                }
            }
    #else
            EasyLink_Status result = EasyLink_transmit(&txPacket);

            if (result == EasyLink_Status_Success)
            {
                /* Toggle LED1 to indicate TX */
                PIN_setOutputValue(pinHandle, Board_PIN_LED1,!PIN_getOutputValue(Board_PIN_LED1));
            }
            else
            {
                /* Toggle LED1 and LED2 to indicate error */
                PIN_setOutputValue(pinHandle, Board_PIN_LED1,!PIN_getOutputValue(Board_PIN_LED1));
                PIN_setOutputValue(pinHandle, Board_PIN_LED2,!PIN_getOutputValue(Board_PIN_LED2));
            }
    #endif //RFEASYLINKTX_ASYNC
        }
    }

    static void i2cTaskFnx(UArg arg0, UArg arg1)
    {
        I2C_Handle i2c;
        I2C_Params i2cParams;
        I2C_Transaction i2cTransaction;

        I2C_init();
        /* Create I2C for usage */
        I2C_Params_init(&i2cParams);
        i2cParams.bitRate = I2C_400kHz;
        i2c = I2C_open(Board_I2C_TMP, &i2cParams);

        /* Common I2C transaction setup */
        i2cTransaction.writeBuf = 0;
        i2cTransaction.writeCount = 0;
        i2cTransaction.readBuf = rxBuffer;
        i2cTransaction.readCount = 24;
        i2cTransaction.slaveAddress = ArduinoAddr;

        while (1) {
            if (I2C_transfer(i2c, &i2cTransaction)) {
                a = (rxBuffer[0] << 8) | (rxBuffer[1]);
                b = (rxBuffer[2] << 8) | (rxBuffer[3]);
                c = (rxBuffer[4] << 8) | (rxBuffer[5]);
                d = (rxBuffer[6] << 8) | (rxBuffer[7]);
                e = (rxBuffer[8] << 8) | (rxBuffer[9]);
                f = (rxBuffer[10] << 8) | (rxBuffer[11]);
                g = (rxBuffer[12] << 8) | (rxBuffer[13]);
                h = (rxBuffer[14] << 8) | (rxBuffer[15]);
                i = (rxBuffer[16] << 8) | (rxBuffer[17]);
                j = (rxBuffer[18] << 8) | (rxBuffer[19]);
                k = (rxBuffer[20] << 8) | (rxBuffer[21]);
                l = (rxBuffer[22] << 8) | (rxBuffer[23]);
            } else {
                /* Error occurred */
                PIN_setOutputValue(pinHandle, Board_PIN_LED2,!PIN_getOutputValue(Board_PIN_LED2));
            }
           
            Task_sleep(100); // Sleep for 100ms before next I2C transaction
        }
    }

    int main(void)
    {
        /* Call driver init functions */
        PIN_init(BoardGpioInitTable);
        GPIO_init();
        I2C_init();
        Board_initGeneral();

        IOCPortConfigureSet(IOID_29, IOC_PORT_RFC_GPO0, IOC_IOMODE_NORMAL);
        IOCPortConfigureSet(IOID_30, IOC_PORT_RFC_GPO1, IOC_IOMODE_NORMAL);

        pinHandle = PIN_open(&pinState, pinTable);
        if(!pinHandle) {
            System_abort("Error with PIN_open");
        }

        /* Clear LED pins */
        PIN_setOutputValue(pinHandle, Board_PIN_LED1, 0);
        PIN_setOutputValue(pinHandle, Board_PIN_LED2, 0);

        /* Set the range extender pin to high */
        PIN_setOutputValue(pinHandle, IOID_28, 1);

        /* Initialize task */
        Task_Params_init(&txTaskParams);
        txTaskParams.stackSize = RFEASYLINKTX_TASK_STACK_SIZE;
        txTaskParams.priority = RFEASYLINKTX_TASK_PRIORITY;
        txTaskParams.stack = &txTaskStack;

        Task_construct(&txTask, rfEasyLinkTxFnx, &txTaskParams, NULL);

        /* Initialize I2C task */
        Task_Params_init(&i2cTaskParams);
        i2cTaskParams.stackSize = I2C_TASK_STACK_SIZE;
        i2cTaskParams.priority = I2C_TASK_PRIORITY;
        i2cTaskParams.stack = &i2cTaskStack;

        Task_construct(&i2cTask, i2cTaskFnx, &i2cTaskParams, NULL);

        /* Start BIOS */
        BIOS_start();

        return (0);
    }



    Hey i got the code working... Thanks... But i want to increase the transmit power how do i do it?
    presently rssi when receiver is closeby, I get it to be -14dBm
  • Presently using this code I could transmit till 250 meters, but I want to transmit for 1 kilometer atleast... How do I increase the range of this transmission. 

  • Hi,

    I believe there is an EasyLink API to set TX power. Did you look in the EasyLink header file?

    To increase your range please go through this app note and the advice given:

    https://www.ti.com/lit/swra370 

    Cheers,

    Marie H