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.

Read/Write EEPROM with CC1310 using I2C

Other Parts Discussed in Thread: CC1310, CC1350STK, CC1350

Hi all,

I am having issues with the use of I2C: I setup the configuration board file with the missing part of I2C, now I'm trying to read and write a 256K EEPROM Atmel. To read this EEPROM I need to first configure the I2C slave address, then I have to configure the memory address and then I can start reading/writing ... I can do this with the CC1310? How do I set the memory address? I am confused and I do not find an example to help me

  • Please take a look at the rfWsnDmNode example for the CC1350STK. It uses I2C to communicate with several of the sensors on the sensorTag.

    BR

    Siri
  • Hi, there is an example which might help you.
    In CCS, go to the resource explorer. Choose the CC1350 SensorTag, TI Driver Examples and the the I2C examples.
    It's a example application to read temperature value from a TMP007 I2C temperature sensor.
  • Hi,
    thanks for the reply, I had already seen that example, but are not sure if it's right for me. To set the memory address and then read it, I have to do it in one or two steps? On EEPROM data sheet seems that the write operation can make in a single step, while the reading needs first write the address memory on 2 byte and then start the memory read.
  • For the Temp_sensor example, you can define the I2C address for your I2C device in the board.h file...

  • How? I use "i2cTransaction.slaveAddress".... I just connected the oscilloscope to monitor the SCL and SDA signals: the first 8 bits should be the slaveAddress, but it is not so: the first 2 bits are lost, so if I send 10100001, I read only 100001. why?

  • Any suggestions? I'm also seeing that if I write / read more than one byte, this does not appear on the oscilloscope because the SCL clock ends.
  • I think I've solved and I hope this can help someone else:

    the issue lay in the fact that the slave address must contain only the 7 most significant bits of EEPROM address, so you have to do a right shift of one bit. If EEPROM address is 0xA0 (10100000) in write mode and 0xA1 (10100001) in read mode, you must write:

    i2cTransaction.slaveAddress =  0xA0 >>1;

    or 

    i2cTransaction.slaveAddress =  0xA1 >>1;

    then 

    i2cTransaction.slaveAddress = 0x50;

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

    Real Example:

    I2C_Handle i2cHandle;
    I2C_Params i2cParams;
    I2C_Transaction i2cTransaction;

    // POWER_ON EEPROM...

    I2C_Params_init(&i2cParams);
    i2cParams.bitRate = I2C_100kHz;
    i2cHandle = I2C_open(CC1310_I2C0, &i2cParams);

    uint8_t txBuf[4];
    uint8_t rxBuf[4];

    if (i2cHandle)
    {
    txBuf[0] = 0x1;
    txBuf[1] = 0x1;
    txBuf[2] = 0x42;


    i2cTransaction.writeBuf = txBuf;
    i2cTransaction.writeCount = 3;

    i2cTransaction.readBuf = rxBuf;

    i2cTransaction.readCount = 0;

    i2cTransaction.slaveAddress = 0x50;

    if(I2C_transfer(i2cHandle, &i2cTransaction)) // now I write 0x42 on memory address 0x1 | 0x1<<8
    {

    i2cTransaction.writeBuf = txBuf;
    i2cTransaction.writeCount = 2;

    i2cTransaction.readBuf = rxBuf;
    i2cTransaction.readCount = 1;

    i2cTransaction.slaveAddress = 0x50;

    if(I2C_transfer(i2cHandle, &i2cTransaction)) // now I read on memory address 0x1 | 0x1<<8
    {
    // .. SUCCESS ...
    }
    else
    {
    System_printf("ERROR read\n");
    }
    }
    else
    {
    System_printf("ERROR write\n");
    }

    I2C_close(i2cHandle);

    // POWER_OFF EEPROM...
    }

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

    bye bye.

  • There is a issue regarding code in eeprom. while in debug mode it was showing issue at " if(I2C_transfer(i2cHandle, &i2cTransaction)) " it was not going inside i2c_transfer. I am sharing the code above. please give me a solution to fix it. I modified the i2ctmp007 example code and wrote the eeprom bt removing temp code.

    /*
    * ======== eeprom.c ========
    */
    #include <stdint.h>
    #include <stddef.h>
    #include <unistd.h>

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

    /* Example/Board Header files */
    #include "Board.h"
    #include "System.h"


    /* Slave Addresses */
    //i2cTransaction.slaveAddress = 0xA0 >>1;
    //i2cTransaction.slaveAddress = 0xA1 >>1;
    //i2cTransaction.slaveAddress = 0x50;


    /*
    * ======== mainThread ========
    */
    void *mainThread(void *arg0)
    {
    uint8_t txBuffer[4];
    uint8_t rxBuffer[4];
    I2C_Handle i2cHandle;
    I2C_Params i2cParams;
    I2C_Transaction i2cTransaction;

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

    /* Turn on user LED */
    GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);

    /* Create I2C for usage */
    I2C_Params_init(&i2cParams);
    i2cParams.bitRate = I2C_100kHz;
    i2cHandle = I2C_open(Board_I2C0, &i2cParams);
    if (i2cHandle)
    {
    /* buffer registers */
    txBuffer[0] = 0x01;
    txBuffer[1] = 0x01;
    txBuffer[2] = 0x42;

    //write buffer
    i2cTransaction.writeBuf = txBuffer;
    i2cTransaction.writeCount = 3;

    //read buffer
    i2cTransaction.readBuf = rxBuffer;
    i2cTransaction.readCount = 0;

    //slave address
    i2cTransaction.slaveAddress = (0x50);

    /* now i write 0x42 on memory address 0x1 | 0x1 << 8 */
    if(I2C_transfer(i2cHandle, &i2cTransaction))
    {
    System_printf("success");
    i2cTransaction.writeBuf = txBuffer;
    i2cTransaction.writeCount = 2;

    i2cTransaction.readBuf = rxBuffer;
    i2cTransaction.readCount = 1;

    //slave address
    i2cTransaction.slaveAddress = (0x50);

    /* now i read on memory address 0x1 | 0x1 << 8 */
    if(I2C_transfer(i2cHandle, &i2cTransaction))
    {
    //success
    }
    else
    {
    System_printf("ERROR read");
    }
    }
    else
    {
    System_printf("ERROR write");
    }
    }

    /* Deinitialized I2C */
    I2C_close(i2cHandle);

    //Turn OFF EEPROM
    return (NULL);
    }