Hello ,
I need help to understand I2C programming for Microcontroller.
1. Initializing I2C
2. start I2C
3. stop I2C
4.ACK for I2C
5. NAK for I2C
I am writing function one bye one. if there is any mistake. let me know
1. Initializing I2C
2. start I2C
3. stop I2C
4.ACK for I2C
5. NAK for I2C
If above all points are correct then I want to write another function, so please tell me if there are any mistake ?
I need help to understand I2C programming for Microcontroller.
1. Initializing I2C
2. start I2C
3. stop I2C
4.ACK for I2C
5. NAK for I2C
I am writing function one bye one. if there is any mistake. let me know
1. Initializing I2C
Code:
void I2C_Init()
{
SDA = 1;
SCL = 1;
}
2. start I2C
Code:
void I2C_Start()
{
SDA = 0;
SCL = 0;
}
3. stop I2C
Code:
void I2C_Stop()
{
SCL = 0;
SDA = 0;
SCL = 1;
SDA = 1;
}
4.ACK for I2C
Code:
void I2C_Ack()
{
SDA = 0;
SCL = 1;
SCL = 0;
SDA = 1;
}
5. NAK for I2C
Code:
void I2C_Nak()
{
SDA = 1;
SCL = 1;
SCL = 0;
SDA = 1;
}
If above all points are correct then I want to write another function, so please tell me if there are any mistake ?