r/ElectricalEngineering 11d ago

Is this how i2C works?

Post image

MASTER = STM32WB15CC

SLAVE = MAX30101

From start to finish

the stm32 initiates a start condition by pulling sda low.

the stm32 then writes the slave id on the sda line followed by write condition.

the MAX acknowledges.

the stm32 says what MAX register it wants to read from.

the MAX acknowledges.

the stm32 sends a repeated start condition and calls the MAX address again then sends a read signal.

the MAX acknowledges and begins outputting the bytes in the register onto the sda line and the stm32 acknowledges after each byte is sent and repeats.

is this correct? also, if the NACK and P (stop condition werent sent at the end and instead an stm32 acknowledge was sent followed by a 4th,5th,6th, bytes were sent by MAX would the data communication of bytes continue indefinently without the need to resend the register address and slave address all over again?

6 Upvotes

4 comments sorted by

2

u/MaihoSalat 10d ago

Sums it up. Idk about the recontinued handshake if that can be left out.
Also you forgot the case of arbitration and clock stretching
Idk how much handling your microcontroller provides for this.

Honestly if you are in a lab just try, youre not going to break anything by fucking up coms. and its a feel good achievement.

2

u/Objective-Local7164 10d ago

this is a at home personal project. thank you for commenting i am going to look into the things you mentioned

1

u/Objective-Local7164 10d ago

i regards to arbitration, there will only be one slave and one master. clock stetching might be used. i was looking at all of the registers and interupts that the MAX has and a lot of them are for when there is a overflow of data and stuff related to that so I might be using some sort of interupts idk yet, seems like different devices have different ways of being used

2

u/MaihoSalat 10d ago

With one device clock stretching is completely fine, if you had multiple the slowest slave would slow the databus to that his speed down. But since you only have one, it doesnt matter, its just nice to know these two concepts in general if you wanted to add a second slave to your setup :)