This topic explains how to configure two SUB-20 boards as a I2C master and slave and establish communication between them
We will use the SUB-20 tool application for this demonstration. All the pictures are attached in an archive, see at the bottom of the post
SETUP. Connect boards using 3 wires
MASTER SLAVE COLOR ON PICTURE
SCL GPIO HEADER PIN 1 <-> SCL GPIO HEADER PIN 1 RED
SDA GPIO HEADER PIN 2 <-> SDA GPIO HEADER PIN 2 GREEN
GND GPIO HEADER PIN 34 <-> GND GPIO HEADER PIN 34 WHITE
LAUNCH TWO INSTANCES OF THE SUB20-TOOL APPLICATION
SLAVE CONFIGURATION
SELECT SUB-20 TOOL INSTANCE FOR THE SLAVE DEVICE
We choose the top one(SN 0000) to be a master and the bottom one(SN 041C) to be a slave
SET THE SLAVE ADDRESS
On I2C tab, put slave address into the "Slave addr(hex)", we use 43. This is a hexadecimal value, click the "Set Config" button on the right
FIFO CONFIGURATION
On the FIFO tab check the I2C checkbox and click the "Set Config" button
6) WRITE DATA TO THE SLAVE FIFO
On the FIFO, put the data in the "Data(hex)" field. This is a white space separated list of hexadecimal data bytes
MASTER CONFIGURATION
SET I2C SCL FREQUENCY
On the MASTER I2C Tab, write the I2C clock frequency into the "Freq(Hz)" field. This is a decimal value in Hz. We use 100000Hz
Click the "Set" button
8) I2C BUS SCAN
On the MASTER I2C Tab, click the "Scan" button. The master should find one I2C slave device
9) READING DATA
On the MASTER I2C Tab, put the number of bytes to read, we put 8 and click the "Read" button
You can see that master is reading 02 03 ... 08 ff. This is because the first scan procedure is using a I2C read operation to find out what slaves are available.
LIMITATIONS: Please note that the slave device WILL NOT be found if the slave FIFO is empty. It should contain at least one dummy byte prior the "scanning". If the number of bytes to read exceeds the number of bytes in the FIFO the buffer is padded with ff at the end
I2C Master/Slave communication using two SUB-20 boards
Moderator: serg
I2C Master/Slave communication using two SUB-20 boards
- Attachments
-
- master_slave_i2c.zip
- pictures in archive
- (2.72 MiB) Downloaded 2532 times