Skip to main content

Write condition data frames for I2C communication

Inter-Integrated Circuit



So here we are going to learn how to transmit data from master to slave. Data frame will remain same but what changes is slave address, memory address and data to send to slave.

Please go through the below frame that you have to follow while sending data to slave.

 So above image will help you to understand the  basic writing principle of  master into slave.

Steps to follow:
  • Send start bit so that each slave will get notification that some master is going to start communication.
  • Then master have transmit so that a he can communicate with a specific slave master wants to communicate among many.
  • Master will then inform whether he wants to write data in slave by sending 0 .[in case of write data, no need to send this as by default 0th bit of slave address is 0 ( i2c transmits MSB first ), so (higer 7 bit  is slave address) slave get info as master wants to write]
  • After that acknowledge bit is transmitted to confirm that salve is understanding what master wants to convey. 
  • After selecting slave and informing slave type of operation master wants to perform, master will transmit memory address so that slave will get to know that master wants to access this specific memory location in me.
  • After that acknowledge bit is transmitted to confirm that salve is understanding what master wants to convey. 
  • After accessing a specific memory location in a specific slave, master will transmit the data that master wants to write in that memory address.
  • After that acknowledge bit is transmitted to confirm that salve is understanding what master wants to convey.
  • After that, once data written in one memory location, master will send stop bit,
  • If master have more data to send , repeat the process in loop.
Programming algorithm:
Before proceeding with programming algorithm, please got through  last post so that you can get idea of each condition as I will not write whole program, I will mention algorithm(flow). 


void i2c_write_data(unsigned char sa,unsigned char addr,unsigned char Data)
{
i2c_start();
i2c_write_byte(sa);
i2c_ack();
i2c_write_byte(addr);
i2c_ack();
i2c_write_byte(Data);
i2c_ack();
i2c_stop();
}



here 
sa      : slave address
addr  : memory address
Data : data to write in slave

Video:


Hope you all like this post and I wish this proves useful to you.
Keep sharing & give your views about post in comments.
Comments are always welcomed for better improvement.

Thanks :)
Please write comments if you find anything needs to be more clear, incorrect, or you want to share more information about the topic discussed above 











Comments

Translate to your language

Popular posts from this blog

Different Stages of I2C communication

Different Stages Of I2C

How to import Pygame in pycharm

hi, how are you today

Working demonstration of UART communication using 2 8051 uController on Proteus with Embedded C code.

Here we are going to use 2 at89c51 uControllers just to understand UART communication in 8051.