iic_write

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iic_write

2,040 Views
markross-smith
Contributor I

Hi,

I am using an MMA8451 (on a breakout board) with an MSP430G2553 processor.  From the MMA8451 Application Notes I see many uses of "IIC_Write()" commands.  Are these pseudo-code instructions or is there a preferred library that I can use with those same commands?

BTW, I have already completed the project on an Arduino platform using the 'wire.h' library and that worked perfectly.  I would prefer something similar for the MSP.

Thanks,

Mark

Labels (1)
0 Kudos
Reply
4 Replies

1,660 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hi Mark,

I am afraid NXP does not provide any MMA8451Q code examples or library for TI's MSP430 MCU family. 

We do have several examples mainly for NXP's Kinetis, LPC or i.MX families. Either as part of the ISSDK or simple bare-metal code examples.

If I remember well, the code published in MMA8451Q application notes was written for the 8-bit MC9S08QE8 MCU and the function IIC_Write() simply writes a byte to the MMA8451Q register. 

The MMA8451Q uses a well known combined format that looks as follows.

Writing to the MMA8451Q with SA0 = 0:
1. Send a start sequence
2. Send 0x38   // MMA8451Q slave address with the R/W bit low or 0x1C<<1
3. Send the internal register number you want to write to
4. Send the data byte
5. [Optionally, send any further data bytes]
6. Send the stop sequence.

pastedImage_5.png

Reading from the MMA8451Q with SA0 = 0:
1. Send a start sequence
2. Send 0x38   // slave address with the R/W bit low or 0x1C<<1
3. Send internal address of the register you want to read from
4. Send a start sequence again (repeated start)
5. Send 0x39   // slave address with the R/W bit high or (0x1C<<1)|0x01
6. Read data byte from the addressed register
7. [Optionally, read any further data bytes]
8. Send NAK and the stop sequence.

pastedImage_6.png

Best regards,

Tomas

0 Kudos
Reply

1,660 Views
markross-smith
Contributor I

Hi Tomas,

Thank you for your response - I have a better idea now how I2C works.  However, I am still confused about the use of the I2C_Read() and I2C_Write() functions that you use in your Bare Metal examples without any apparent libraries from which they are derived.  Are they specific to the FRDM-KL25Z platform and therefore not available for the MSP430?  When I started my project using an Arduino I was able to use very similar functions contained in Wire.h, but that library does not work with the MSP430.

Any clue as to the I2C_Write() and _Read() functions will be greatly appreciated.

Regards,

Mark

0 Kudos
Reply

1,660 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hi Mark,

Yes, these functions are specific to the KL25Z MCU.

I assume there will be similar functions available for the MSP430 MCU family and would suggest you to use the TI E2E community for further information.

Best regards,

Tomas

0 Kudos
Reply

1,660 Views
markross-smith
Contributor I

Hi Tomas,

Thanks.  Ti do not have similar library functions but I have been able to write my own Transmit and Receive functions that seem to work.

Regards,

Mark

0 Kudos
Reply