cancel
Showing results for 
Search instead for 
Did you mean: 

About I2C Bus

lorenzo meneghello
Associate II
Posted on December 21, 2016 at 16:03

Hi all,

I'm new on ST device, i'm trying to test the I2C bus but I can't understand how it works.. I do not want to use the HAL library but manage directly the register, but the I2C Interface on ST produce the state of transmission (0x08,0x10,0x28...) like other uC? or it manages all the transmission?

Thanks.

Lorenzo.

12 REPLIES 12
Posted on December 24, 2016 at 13:16

Ok I'll try with another device on the bus, but the correct code for master trasmission are:

1. Load the slave Adress on the I2C1->TXDR or I2C1->CR2 'SADD' register? 

2. Set the start bit

Thanks.

Lorenzo

Merry christmas

Posted on December 24, 2016 at 13:23

If talking to a non MCU based slave device, a simple SW I2C could probably get you going and test if the HW is fine (by sweeping all slave addresses to find out which one is acknowledged. HW I2C is mandatory when clock stretching is needed, managed under interrupt or to behave as slave function.

Otherwise, this will get you started :

https://community.st.com/0D50X00009XkW1mSAF

Mon2
Senior III
Posted on December 25, 2016 at 14:48

Lorenzo - why not just bit-bang out the I2C specification ? Have done this in the past with assorted microcontroller and is very clean and straight forward to understand the interface.

Have a review of AN4655 (section 2.5.3 I2C master bit-banging sequence).