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.

CC2533 I2C

Other Parts Discussed in Thread: CC2533, CC2541

Is there any I2C code examples I can follow for my CC2533 Develop kit?  I am not sure how to utilize the hardware I2C PINS on CC2533

Thank you for your attention.

One moe question : in the data sheet of CC2533, you mentioned that there are internal 20K OHM pul-up resistors, does that mean I do not need any external pull-up resistors? Since I am new to all your products, I really need some sample code to startup, for example, how can I program an I2C start condition?

I am sorry for bothering all the E2E TI people, but I emailed your "customers service", they refused to give any assistance neither.

  • I assumed that I need to set I2CCFG.ENS1 and I2CCFG.STA bits, on the data sheet it says:"When the I2C bus is free, it generates a START condition, sends the slave address, and transfers a transmit direction bit."  since now CC2533 is working as a Master Tx, where can I set the slave address and the direction bit?

    Thanks

  • Hi XY CH,

    Have you looked in the CC2533 Userguide? http://www.ti.com/litv/pdf/swru191b

    I2C chapter starts on page 173, I think it answers all your questions.

    /Fredrik

  • Thank you since I am new to I2C it seems to be difficult to me to implement.

    I do have read through this section for several times. I would like to have my CC2533 works as a Master Transmitter and setup my ADC. I have the following simple testing code:

        I2CCFG = 0x82;   // Set CR2 = 1; CR1 = 1; CR0 = 0 Setup clock rates
        I2CDATA = 0x90;  // Slave Address + R/W (=0)
        I2CCFG |= 0x60;  //Set I2CCFG.ENS1 and I2CCFG.STA bits to transmit this address to the slave
        halMcuWaitMs(200);  //wait 200 us

    Then I use

       utilLcdDisplayValue(HAL_LCD_LINE_1, "I2CSTAT", (int32)I2CSTAT,"/n");

    to display the I2CSTAT register on my LCD. I am expected a value of 24 (that is 0x18) because the SLA+W is transmitted. However, I can only see an 8. which means only a START condition has been transmitted.

    Do I need to do more initialization other than clock rate settings? Would you please suggest a I2C command routine that I can follow?

    Thank you 

  • Hello XY CH,

    the user guide of the CC2533 is IMHO not clear.

    To start the transmission of each I2C message you have to write the I2CCFG register. If you don't do it, it will not execute the next command. Please read the following example of implementation - The MMA_W and MMA_R are the address of the device with a Read or Write Flag. Don't forget that the implementation also depends of both chips specifications.

    // I2C status for the I2CSTAT register of the CC2533

    // Arbitration codes not included here since we have only one master

    #define SR_SENT 0x08
    #define RS_SENT 0x10
    #define SLAW_ACK_SENT 0x18
    #define SLAW_NACK_SENT 0x20
    #define DATA_ACK_SENT 0x28
    #define DATA_SENT 0x30
    #define SLAR_ACK_SENT 0x40
    #define SLAR_NACK_SENT 0x48
    #define DATA_ACK_RECV 0x50
    #define DATA_NACK_RECV 0x58

    // I2C functions for I2CCFG

    #define I2C_SR  0xE2 // speed min if speed max :
    #define I2C_SP  0xD2 // speed min if speed max :
    #define I2C_DO  0xC2 // speed min if speed max :

    void I2CSend( uint8 addr, uint8 val)
    {
            // Sent start condition and wait for it to be received
            I2CCFG=I2C_SR;
            waitI2CStat(SR_SENT);
           
            // Send Device Address
            I2CDATA=MMA_W;
            I2CCFG=I2C_DO;
            waitI2CStat(SLAW_ACK_SENT);
           
            // Send Register address
           
            I2CDATA=addr;
            I2CCFG=I2C_DO;
            waitI2CStat(DATA_ACK_SENT);
           
            // Send Register Value
           
            I2CDATA=val;
            I2CCFG=I2C_DO;
            waitI2CStat(DATA_ACK_SENT);
           
            // Send Stop Condition
           
            I2CCFG=I2C_SP;
           
    }
           
    uint8 I2CRead( uint8 addr)
    {       
           
            // Sent start condition and wait for it to be received
            I2CCFG=I2C_SR;
            waitI2CStat(SR_SENT);
           
            // Send Device Address
            I2CDATA=MMA_W;
            I2CCFG=I2C_DO;
            waitI2CStat(SLAW_ACK_SENT);
           
            // Send Register address
           
            I2CDATA=addr;
            I2CCFG=I2C_DO;
            waitI2CStat(DATA_ACK_SENT);
                 
            // Send Restart condition
           
            I2CCFG=I2C_SR;
            waitI2CStat(RS_SENT);
           
            // Send Device Address Read
           
            I2CDATA=MMA_R;
            I2CCFG=I2C_DO;
            waitI2CStat(SLAR_ACK_SENT);
           
            // Do the transfer
           
            I2CCFG=I2C_DO;
            waitI2CStat(DATA_NACK_RECV);
            // Send Stop Condition
           
            I2CCFG=I2C_SP;
           
            return I2CDATA;

    }

  • Dear Spyke,

    I'm also using CC2533 for I2C interface programming as master transciver.

    I would like to know the definition of "MMA_W" , "MMA_R" and waitI2CStat(SLAW_ACK_SENT)

    ps. would it be like this:      #define waitI2CStat(x) {while(I2CSTAT!=x);}

    Thanks for your help!

    Btw, <<HAL Driver API.pdf >> has define follow functions:

    HalI2CInit ()

    HalI2CReceive ()

    HalI2CSend ()

    would you give the source code and header file to me?

    my email address: zjpeng@gemstar.com.cn

     

    Best regards,

    Jack

     

     

  • Hi , jack / spyke

     

    Im also facing problem when creating the I2c source code ,and would like to ask for the I2c c file and the header file

    my e-mail address is alexsignji@yahoo.com

     

    thanks alot

    Regards,

    Alex

  • Hi everyone!  

    I am trying to find those files as well... Is any chance that I can get them?

    My email address  flortiforum@gmail.com

    Thanks in advance!

  • Hi ,
    I am facing same issue cc2541 reading , May I have "waitI2CStat" code ? thanks !

    BR
    Shijun
  • Dear Spyke ,
    Could you please share your waitI2CStat sub-route with me ? because I am facing same issue . thanks a lot !
    BRShijun