Jump to content
43oh

Recommended Posts

0x0 is the general call address. It is a reserved address. But it is optional. For the most part, if a i2c device isn't designed to use the general call address, it ignores it, like it would any other address except it's own. So it depends on which i2c devices you are using. So no real harm comes from sending 0x0 unless the i2c device uses it, and the following byte is then a valid command as well.

 

As a command byte, not an address byte, some require it. A i2c expander could use 0x0 to mean turn off all outputs.

Link to post
Share on other sites
  • 3 weeks later...

Hi,

 

I am working on msp430g2553 to interface with pressure sensor(BMP085). As this involves I2c communications, I have started off with the algorithm to be followed.

 

Obviously, my first would be to initialize  I2c communications by writing to control registers. But I am little bit confused whether i have to initialize UART mode aswell?

 

First of all do we need to initialize any one of the modules(i.e. USART, USCI, USI)  before going for the specific communication type?  

 

Please can u help me?

Link to post
Share on other sites

Are you using Energia or are you using IAR/CCS/GCC? In the first case you should include the I2C (TWI.h) driver and call it's begin method. In the latter case you need to set up the peripheral you will use for I2C, you don't need to set up UART in either case.

Both UART and I2C are types of serial connections (as are SPI and USB), but they are essentially all different interfaces.

In the MSP430 the USART, USCI and USI peripherals combine serial logic in a single block, saving a little silicon space. These are as follows:

  • USART: either UART or SPI mode
  • USCI: UART or SPI mode + I2C or SPI mode
    • UART + I2C
    • UART + SPI
    • SPI + I2C
    • 2 x SPI
  • USI: either I2C or SPI mode

Since all of these peripherals are serial drivers, you can mostly alter their behaviour to support another connection. There is an application note on how to use the USI for UART mode, but it does require a bit more code and is heavier on your CPU resources.

While USCI is essentially always a pair of A (left of the + mark) and B (right of the + mark) peripherals, they may not always be implemented in full. You could only have USCI_A0, or only USCI_A0, USCI_B0 and USCI_A1.

Link to post
Share on other sites

Hi roadrunner,

 

  I am using CCS Ver 5. Thanks for the information....   According to what i have gathered from ur reply is that there is no need to initialize UART or any other modes for my I2C setup......

 

AM I RIGHT?

 

Here is my i2c initialization code

Please correct me if anything is wrong, or anything to be added..   In fact  i followed some other thread where it was posted... 

 
 
void initialise_I2C(void)
{
UCB0CTL1 |= UCSWRST; // Enable SW reset
   UCB0CTL0 = UCMST + UCMODE_3 + UCSYNC; // I2C Master, synchronous mode
   UCB0CTL1 = UCSSEL_2 + UCSWRST; // Use SMCLK, keep SW reset
   UCB0BR0 = 10; // fSCL = 1Mhz/10 = ~100kHz
      UCB0BR1 = 0;
      UCB0I2CSA=0x77;
      UCB0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
      UCB0I2CIE = UCNACKIE;
      IFG2 &= ~(UCB0TXIFG + UCB0RXIFG);
          IE2 |= UCB0RXIE + UCB0TXIE; // Enable RX and TX interrupt
}
After this I am going for the BMP085_initialisation(); function.
Is it correct? or any more configurations required?
Link to post
Share on other sites

Your reply is conflicting. Since you are using CSS you need to set up your (USCI_B0) peripheral for I2C mode.

You appended your initialisation code (setup code), so you are setting it up. Then why do you suggest you don't need to set up anything?

Af far as I can tell, your initialisiation code is fine. Be sure to have global interrupts enabled, go to low power mode (with interrupts enabled) or poll your flags when doing I2C communications; your interrupt will go high on transmission/receival of data, but your ISR won't be called unless you have GIE true.

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...