Home | Projects | Notes > MCU Peripheral Drivers > I2C Application 2: Master Rx (Blocking) (i2c_02_master_rx_blocking.c)

I2C Application 2: Master Rx (Blocking)(i2c_02_master_rx_blocking.c)

 

Requirements

Parts Needed

  1. Arduino board

  2. STM32 board

  3. Logic level converter

  4. Breadboard and jumper wires

STM32 Board and Arduino Board Communication Interfaces

 

i2c-application-communication-2-interfaces

 

STM32 Board and Arduino Board Voltage Levels

 

spi-application-2-stm32-arduino-voltage-levels

Procedure to Read Data from Slave (Arduino)

  1. Master sends command code 0x51 to read the 1 byte of length information from the slave.

  2. Master sends command code 0x52 to read the complete data from the slave. (Reading byte-by-byte based on the length information fetched in Step 1)

  3. (Master displays the received data using semihosting.)

Using printf() to Print Messages in STM32CubeIDE Console

 

Setup

1. Find out the GPIO pins that can be used for IC2 communication

2. Connect STM32 Discovery board with Arduino Uno board I2C pins

 

i2c-application-2-hardware-setup

 

3. Power Arduino board and download SPI slave sketch to Arduino

 

Code

i2c_02_master_rx_blocking.c

Path: Project/Src/

 

Arduino Sketch (002I2CSlaveTxString.ino)

 

Testing

The following snapshots are taken using the Logic Analyzer.

 

Entire Communication

 

i2c-application-2-testing-entire-communication

 

Communication in Detail

 

i2c-application-2-testing-communication-part-1

 

i2c-application-2-testing-communication-part-2

 

i2c-application-2-testing-communication-part-3

 

Cross-Checking using the STM32CubeIDE Console

 

i2c-application-2-testing-stm32cubeide