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.

how to change the MSP430 I2C 8 bit address mode?

Other Parts Discussed in Thread: MSP430F5438A

I used MSP430f5438A.

I want to control the honeywell 3 Axis digital compass IC( I2C protocol ), but the chip address is defined 8 bit.

I can send 0x3C, I shift the address 0x1E, and UCB0CTL1 |= UCTR + UCTXSTT, so MSP430 can send address of 0x3C.


But  I want to read data from compass IC, the data sheet tell me must to send  0x3D 0x06, I can send 0x1E and UCB0CTL1 &= ~UCTR( receive ), but in the receive status , I can't sent the 0x06

Write CRA (00) – send 0x3C 0x00 0x70 (8-average, 15 Hz default, normal measurement)
2. Write CRB (01) – send 0x3C 0x01 0xA0 (Gain=5, or any other desired gain)
3. Write Mode (02) – send 0x3C 0x02 0x00 (Continuous-measurement mode)
4. Wait 6 ms or monitor status register or DRDY hardware interrupt pin
5. Loop
Send 0x3D 0x06 (Read all 6 bytes. If gain is changed then this data set is using previous gain)
Convert three 16-bit 2’s compliment hex values to decimal values and assign to X, Z, Y, respectively.
Send 0x3C 0x03 (point to first data register 03)
Wait about 67 ms (if 15 Hz rate) or monitor status register or DRDY hardware interrupt pin
End_loop

  • See here... http://www.totalphase.com/support/kb/10039/ there's a section on 8-bit addresses.

  • Sending 0x3d 0x06 is impossible. THsi is neitehr a valid 10 bit address, nor does the 7/8 bit addressing allow sending a second 'address' byte in read mode.

    If this is really required by the chip, then it is far, far outside the I2C specification.

    When a start address is required befor ereading, all oteh rI2C chips I know of require a write addressing, hten send the address byte, then a repeated start is done fo read mode and data is read.

    In your case, after sending 0x3d, you can only receive data. Maybe your docs are wrong and you will indeed be able to receive 6 bytes of data after sending 0x3D (without actually sending the 0x06).

    From the description, I seems that your sensor works the same way: after a 0x3c, the first byte sets the address pointer. And on every access, the pointer automatically increases. So you can send 0x3c 0x00 0x70 0xa0 0x00 to write to the first three registers (instead of doing three separate transfers). the address pointe rnow points to 0x03 where the data lies. Then receive 6 bytes with addres 0x3d (0x1e+UCTR clear). Next, set the address pointer back to data start by sending 0x3d 0x03.

    It's also possible that the description is written for a high-level I2C library call, which determines by the 0x3d that this is read mode and takes the 0x06 for the number of bytes to be received.

    In any case, in read mode, the only thing that's sent is the address byte. That's how I2C is defined. And how the hardware I2C support works on MSPs.
    The only exception is 10 bit addressing mode, where the normal address byte is in the range of 0xf0 to 0xf7, which is invalid range for 7 bit addressing. This byte then is acknowledged by all slaves where the upper two address bits match. Then a second address byte follows with the lower 8 address bits. But this doesn't apply to your case, as 0x3c doesn't fall into the 0xf0-0xf7 range :)

**Attention** This is a public forum