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.

CCS/CC1352P: How to transmit data use i2c ?(simplelink sdk 3.2)

Part Number: CC1352P


Tool/software: Code Composer Studio

Hello sir!

I not understand below that

Please tell me, why?

My source is read time data from timer ic by i2c.

Timer ic chip address : 0xd0(wirte), 0xd1(read) 

I2C_Params i2c_params;
I2C_Params_init(&i2c_params);
i2c_params.bitRate = Board_I2C0_MAXSPEED;

I2C_Handle i2cHandle = I2C_open(Board_I2C0, &i2c_params);

Tx_Buffer[0] = 0x00;
Tx_Buffer[1] = 0x58;
Tx_Buffer[2] = 0x00;

I2C_Transaction i2cTransaction;
i2cTransaction.arg = NULL;
i2cTransaction.writeBuf = Tx_Buffer;
i2cTransaction.writeCount = 2;
i2cTransaction.readBuf = Rx_Buffer;
i2cTransaction.readCount = 3;
i2cTransaction.slaveAddress = 0xD0;

if(I2C_transfer(i2cHandle, &i2cTransaction))
{
GPIO_write(Board_STATE_LED3, 0); // GPIO_write() is operating
GPIO_write(Board_STATE_LED2, 0); // GPIO_write() is operating
}
else
{
GPIO_write(Board_STATE_LED3, 1); // GPIO_write() is operating
GPIO_write(Board_STATE_LED2, 0); // GPIO_write() is operating

}

/*===============================================================*/

I2C_Open() is no problem (It is return NULL)

but after run I2C_transfer(i2cHandle, &i2cTransaction) function, the source run Main_assertHandler(uint8_t assertReason)  function

and unlimit loop 

Is it problem about H/W?

 

  • Hi Sung,

    As is stated in the documentation, the read/write bit is appended automatically by the I2C HW. The address for you external timer is thus 0x68.

    Regards,
    Fredrik

  • Thanks your answer.

    I try change device address is 0x68, but result is same

    I used simplelink_cc13x2_26x2_sdk_3_20_00_68 and changed pin map for i2c by syscfg in ccs

    so i guess that my system i2c pin is crash with basic pin(cc1352p_launchlx board) in example source anywhere.

    And i try uart communication, i have same result.

    uart init ok, uart open ok, uart transmit is run Main_assertHandler() function and un-limit rutin

    void Main_assertHandler(uint8_t assertReason)
    {
    Main_assertReason = assertReason;

    #if defined(RESET_ASSERT)
    Csf_assertInd(assertReason);

    /* Pull the plug and start over */
    SysCtrlSystemReset();
    #else
    Hwi_disable();

    while(1)
    {
    /* Put you code here to do something if in assert */
    }
    #endif

    so I acknowledge that assertReason is MAIN_ASSERT_HWI_TIRTOS

    I don,t know, why?

    thanks sir!

  • If I2C_Open returns NULL it is not ok. So there is an error in your initialisation.

    See I2C header file

    /*!
     *  @brief  Open an I2C driver instance.
     *
     *  @pre    I2C_init() has been called.
     *
     *  @param[in]  index    Index in the @p I2C_Config[] array.
     *
     *  @param[in]  params    Pointer to an initialized #I2C_Params structure.
     *                        If NULL, the default #I2C_Params values are used.
     *
     *  @return An #I2C_Handle on success, or @p NULL on an error.
     *
     *  @sa     I2C_init()
     *  @sa     I2C_close()
     */
    extern I2C_Handle I2C_open(uint_least8_t index, I2C_Params *params);
    

    Probably your pin configuration is wrong? Or some other issue in your board.c setup..,

  • Hi Sung,

    Are you using a CC1352P LaunchPad? There is an error on the board unfortunately, so SCL (DIO21) is missing pull-up. See if adding this resistor resolves your problem.

    Regards,
    Fredrik

  • Hi Fredrik

    Thanks for your answer!

    I not used CC1352P LaunchPad and i designed for my system

    And SCL(DIO6), SDA(DIO5) line is pull up by 4.7k, there is changed by sysfig tool in ccs(ver 9.1)

    int main(void)
    {
    Task_Params taskParams;

    UART_Handle uart_Handel;
    UART_Params uart_Params;

    I2C_Params i2cparams;
    I2C_Handle i2c_Handle;

    Board_init();

    UART_init();

    I2C_init();
    //I2CCC26XX_init(i2c_Handle);

    UART_Params_init(&uartParams);
    uartParams.baudRate = 115200;
    UART_open(Board_UART0, &uart_Params);

    I2C_Params_init(&i2cparams);
    i2cparams.bitRate = 0;
    i2cparams.transferMode = I2C_MODE_BLOCKING;

    i2c_Handle = I2C_open(Board_I2C0, &i2cparams);
    if(i2c_Handle == NULL)
    {
    GPIO_write(Board_STATE_LED3, 0); // GPIO_write() is operating    <= This is not run, so I2C_open function is not return 'NULL'
    GPIO_write(Board_STATE_LED2, 0); // GPIO_write() is operatin
    }

    /*===============================================================*/

    }

     1.First try run I2C_transfer() function in main() but system is fail .

    2.Second try run I2C_transfer() function in appTaskFxn(), 

       Ii is success and i read time data by timer ic and check valuable use by debugger expression.

       The valuable is changed ever reading time.

       So I thank that the system and source is right

    3.So I try distinguish by function and make new source and head file (ex PCF8523.h, PCF8523.h : Time IC name)

       and added parameter setting, Timer IC reading function, Timer IC writing function rtc. in PCF8523.c file

    4.New files is added in my project and complete compile and run, but system is fail(run to unlimit routine <- it is same first system fail)

     -> I so thank that the I2C_transfer() function is must run in appTaskFxn() function and return to success time 

    Void appTaskFxn(UArg a0, UArg a1)
    {
    I2C_Handle i2chandle;
    unsigned char tx_data[3];
    unsigned char rx_data[2];

    tx_data[0] = 0x00;
    tx_data[1] = 0x58;
    int_fast16_t i2cstate;

    I2C_Transaction i2ctransaction = {0};
    i2ctransaction.slaveAddress = 0x68;
    i2ctransaction.arg = NULL;

    i2ctransaction.writeBuf = tx_data;
    i2ctransaction.writeCount = 2;
    i2ctransaction.readBuf = NULL;
    i2ctransaction.readCount = 0;

    if(I2C_transfer(i2chandle, &i2ctransaction))
    {
    GPIO_write(Board_STATE_LED3, 0); // GPIO_write() is operating
    GPIO_write(Board_STATE_LED2, 0); // GPIO_write() is operatin
    GPIO_toggle(Board_STATE_LED1); // GPIO_write() is operating
    }

    /* Kick off application - Forever loop */
    while(1)
    {
    Collector_process();
    }
    }

    but the system is not success anymore.

    5.I try make new project is ti514stack sensor and i2c communication, I2C_transfer() function is used in appTaskFxn()

     It is success!

    I don't know and have not solution that. 

    Now i try have solution for a few days but fail every methods

  • Have you reviewed any of the I2C examples found here: dev.ti.com/.../node