| |
I2C device programming - Write data to I2C device
1. Add a new I2C device
- Select "Application" tab.
- Add script as follows in order to add a new I2C device.
| |
clear
I2CDevice i2c1
/Address:58
/ClockRateKhz:100
| |
|
|
|
|
- Click "Send to MF Application" button or Press "F5" key.
- Executed result:
2. Write byte[] data to I2C device
- Use "Write(byte[] buff)" method to send byte array data to I2C device.
- In order to create byte array, use "Util.CreateArrayByte(length)" method.
- Select "Log" tab.
- Check "Display hex format for the I2C data"
- Select "Application" tab.
- Type script as follows.
| |
buff = Util.CreateArrayByte(4)
buff[0] = 0xA0
buff[1] = 0xA1
buff[2] = 0xA2
buff[3] = 0xA3
i2c1.Write(buff)
| |
|
- Click "Send to MF Application" button or Press "F5" key.
- Emulator will log received data through I2C into log list. You can check this log from the Log tab.
- Select "Log" tab.
- Executed result:
|