SLAA908A September   2019  – September 2021 MSP430FR2032 , MSP430FR2032 , MSP430FR2033 , MSP430FR2033 , MSP430FR2153 , MSP430FR2153 , MSP430FR2155 , MSP430FR2155 , MSP430FR2310 , MSP430FR2310 , MSP430FR2311 , MSP430FR2311 , MSP430FR2353 , MSP430FR2353 , MSP430FR2355 , MSP430FR2355 , MSP430FR2422 , MSP430FR2422 , MSP430FR2433 , MSP430FR2433 , MSP430FR2475 , MSP430FR2475 , MSP430FR2476 , MSP430FR2476 , MSP430FR4131 , MSP430FR4131 , MSP430FR4132 , MSP430FR4132

 

  1.   Trademarks
  2. 1Introduction
  3. 2Implementation
  4. 3UART Message Format
    1. 3.1 Write N Bytes to Slave Device
    2. 3.2 Read N Bytes From Slave Device
    3. 3.3 Repeated Start (Read After Write)
    4. 3.4 Repeated Start (Write After Write)
    5. 3.5 Write to Internal Register
    6. 3.6 Read From Internal Register
  5. 4Internal Registers Available
    1. 4.1 Register Summary
    2. 4.2 Baud Rate Generator (BRG)
    3. 4.3 I2C Bus Clock Rates (I2CClk)
  6. 5Performance
  7. 6Application Examples
    1. 6.1 Test With I2C Slave Device
    2. 6.2 Read and Write EEPROM
  8. 7Reference
  9. 8Revision History

Test With I2C Slave Device

In this example, another MSP430FR2311 is used as the I2C slave device, and the I2C slave program is loaded internally You can download the slave program for reference, and you need to add RX interrupts and buffers for correct operation. The slave address is 0x48. When receiving a write command sent by the host device, the data is stored in the buffer area. When receiving a read command sent by the host device, the slave device sends incremental data starting at 0x00.

Figure 6-1 shows the serial port command sent by the I2C master to write data and read the data.

In the write example, the UART data command writes 8 bytes to the I2C slave. The command is composed of these bytes:

  • The first byte is 'S' (0x53) to indicate I2C start
  • The second byte indicates the slave address and write command (0x48 << 1 | 0 = 0x90)
  • The third byte indicates the length of the write data (0x08)
  • The next 8 bytes are the data to write to the slave (0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88)
  • The last byte is 'P' (0x50) to indicate I2C stop

In the read example, the UART data command reads 8 bytes from I2C slave.

  • The first byte is 'S' (0x53) to indicate I2C start
  • The second byte indicates the slave address and the read command (0x48 <<1 | 1 = 0x91)
  • The third byte indicates the length of the read data (0x08)
  • The last byte is 'P' (0x50) to indicate I2C stop
GUID-6B7ABFF5-26B1-4234-8FBD-6D9B3E2C7CDC-low.pngFigure 6-1 I2C Write and Read

Figure 6-2 shows the waveform of the I2C write data. From the figure, we can see the start bit, slave address, write command, write data and the end bit in SDA line.

GUID-CD1904AA-545A-4E0D-8970-EEFA0C7842EC-low.pngFigure 6-2 I2C Write Data Waveform

Figure 6-3 shows the waveform of the I2C read data. From the figure, we can see the start bit, slave address, read command, read data and the end bit in SDA line.

GUID-42E83597-EB59-48AD-BCAB-D369EB5B35C8-low.pngFigure 6-3 I2C Read Data Waveform