This question is mainly to check if I understood i2c protocol and hardware correctly. Because pin modes confusing me a little, ia m jsut a beginner.
- I2C SDA and SCL lines are pulled high with pull up resistor. In my case I use 4k resistor.
- Master pulls SDA line to ground and starts clocking on SCL line after that, and thats called start condition.
- Master send out an adress to slave and r/w bit.
Here is what confuses me.
- Master reconfigures the pin SDA in to input mode to recieve ACK bit while slave reconfigures its input pin to output pin and pulls SDA line to ground to send and ACK bit.
And then same repeats with the rest of the bytes untill stop condition is met. The question is, is pin actually reconfigured from output to input on the master to read the ACK bit or there is some other mechanisms that i am not aware of?
From what I read on AVR forums I can do the following: In case my SDA pin is on PB0, to make it high I would switch PB0 to input without internal pull up (leaves it floating). To make pin go low I would set it to output low. While I am input mode I could also read the input from the same pin.
Please correct me if i am wrong.