Jump to content
Rei Vilo

[Energia Library] Software I2C Master for MSP430G2553

Recommended Posts

@ArcticSaturn: 

 

The first byte transmitted out on the I2C bus is a composition of the slave address and the read/write bit.

 

Since the read/write bit occupies the least significant bit position in this first byte, the address appears to be incorrect but it's okay.

 

For example, if the slave address = 0x04 and the R/W bit = 0 (write command) then the first byte looks like 0x08.

 

Here's a C code snippet to elaborate:

...
   
    /**************************************************************************
     * Start reading sensor by sending the START condition
     **************************************************************************/
    i2c_start();

    /**************************************************************************
     * Then write out the sensor I2C address + the Read Bit
     * (  I2C Address << 1)|READBIT
     * ( (0x28<<1) | 0x01 ) = 0x51
     **************************************************************************/
    i2c_out_byte( ( SLAVE_ADDRESS<<1 ) | READBIT  );

    /**************************************************************************
     * Now see if the sensor responded to the command by checking
     * the ACK bit.
     **************************************************************************/
    AckBit = i2c_readackbit();
...

Does that make sense?

Is that what you are seeing?

 

 

Share this post


Link to post
Share on other sites

@@zeke

 

yes it does. I just read the spec from Sensirion and they say1000,000 + R/W bit. In my working code I always started with 0x80 so my assumption was address is 0x80 (which is wrong).

 

Thanks for pointing me to it!

 

Have a nice weekend!

Share this post


Link to post
Share on other sites

@ArcticSaturn: Excellent!

 

Yeah, this detail tripped me up too when I first attempted I2C comms. That's why I commented my C code - to remind myself later on.

 

I hope you have a nice, warm weekend too!

Share this post


Link to post
Share on other sites

Hi Rei,

I try to use your library with my CC3200. I want to attach two vcnl4000 proximity sensors to te board. Because of the fixed I2C address I have to use a software interface.

I have a problem with your library. When a try to compile I get the following error:

C:\Users\myway\Documents\energia-0101E0015\hardware\cc3200\libraries\I2C_SoftwareLibrary\I2C_SoftwareLibrary.cpp: In function 'void delayI2Cms(uint16_t)':
C:\Users\myway\Documents\energia-0101E0015\hardware\cc3200\libraries\I2C_SoftwareLibrary\I2C_SoftwareLibrary.cpp:33:48: error: '__delay_cycles' was not declared in this scope
     while (delay--) __delay_cycles(TICKS_PER_MS);
                                                ^
C:\Users\myway\Documents\energia-0101E0015\hardware\cc3200\libraries\I2C_SoftwareLibrary\I2C_SoftwareLibrary.cpp: In function 'void delayI2Cus(uint16_t)':
C:\Users\myway\Documents\energia-0101E0015\hardware\cc3200\libraries\I2C_SoftwareLibrary\I2C_SoftwareLibrary.cpp:37:48: error: '__delay_cycles' was not declared in this scope
     while (delay--) __delay_cycles(TICKS_PER_US);

Actually I have no idea about the missing function "__delay_cycles".

Can you help me please?

 

Way

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...