• Forums
• Posts
Latest Posts
Active Posts
Recently Visited
Search Results
• Page Extras
• Forum Themes
• AVR Freaks

Author
mukesh12
New Member
• Total Posts : 22
• Reward points : 0
• Joined: 2020/03/21 21:43:21
• Location: 0
• Status: offline
0

Let's take one example, assume we have slave device whose 7 bit slave address is 1001100 and register address is  10000011 (83h). value 12h (0001 0010) stored at register address (83h)

Whats the sequence of data, master sends to read register value of slave ?

Please Note this question is only related to basic understanding I have assumed all values that's are not given from datasheet

crosland
Super Member
• Total Posts : 1936
• Reward points : 0
• Joined: 2005/05/10 10:55:05
• Location: Warks, UK
• Status: offline
+1 (1)
What exactly do you not understand?

Most data sheets for I2C slaves or masters have fairly clear timing diagrams. It would help if you refer to such a data sheet and explain what is not clear.
ric
Super Member
• Total Posts : 26942
• Reward points : 0
• Joined: 2003/11/07 12:41:26
• Location: Australia, Melbourne
• Status: online
+2 (2)
mukesh12
...
Let's take one example, assume we have slave device whose 7 bit slave address is 1001100 and register address is  10000011 (83h). value 12h (0001 0010) stored at register address (83h)

As soon as you talk about "register address" you are going past what is defined in the I2C standard, and it all depends upon what is documented in the datasheet for the particular device you are talking about.
That said, what USUALLY happens is you have to do a dummy write of zero length to the register address you want, which sets the register number in the device but doesn't write any data to it,
and then you do a read, which will read from that same register.
The write is done using 8 bit slave address 0x10011000 = 0x98
The read is done using 8 bit slave address 0x10011001 = 0x99

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
katela
Super Member
• Total Posts : 1745
• Reward points : 0
• Joined: 2013/06/11 05:25:18
• Location: South Africa
• Status: offline
+2 (2)
The datasheet of the I2C slaves devices should explain the steps to write/read  the slave by the master. For example to read from the DS1307 I2C slave device, here are the few steps:

1. Send a START
2. Send I²C address of the SLAVE with the R/W bit low: Addresses the chip. The slave 7-bit address is ‘1101000’., so we will send: 11010000 . After every address byte sent by the Master, the 8th bit determines if the next byte is written or read by the Master: 0 to write and 1 to read.  The least significant bit (8th bit) is 0 in this case as we want to write to the slave (to select it first).
3. Send device register you want to read from: Send: 0x83
4. Send a START sequence again (a repeated start)
5. Send I²C address of the SLAVE with the R/W bit high: Addresses the chip with a read bit: 7-bit address ‘1101000’ plus a 1 bit to read which gives: 11010001. This tells the device the master wants to read data form the selected register.
6. Read data byte from SLAVE
7. Send the STOP sequence.

Free online Microcontroller Tutorials and Projects for Hobbyists and students. From beginners to advanced. Website: www.studentcompanion.co.za
ric
Super Member
• Total Posts : 26942
• Reward points : 0
• Joined: 2003/11/07 12:41:26
• Location: Australia, Melbourne
• Status: online
+1 (1)
katela
...
Send a START sequence again (a repeated start)
...

In almost every situation, it is perfectly acceptable to send a normal STOP sequence, and then a new normal START sequence for the read command.
"Repeated Start" is really only necessary in a multi-master environment to make sure another Master doesn't seize the bus between your write and read commands.

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
katela
Super Member
• Total Posts : 1745
• Reward points : 0
• Joined: 2013/06/11 05:25:18
• Location: South Africa
• Status: offline
0
That's correct ric.

Free online Microcontroller Tutorials and Projects for Hobbyists and students. From beginners to advanced. Website: www.studentcompanion.co.za
mukesh12
New Member
• Total Posts : 22
• Reward points : 0
• Joined: 2020/03/21 21:43:21
• Location: 0
• Status: offline
0
katela
1. Send device register you want to read from: Send: 0x83h
2. Read data byte from SLAVE

Master send only device register 0x83h to read data byte 12h from slave. I do not understand how we get 12h.
When master send register to slave, does slave send data store at that address to master. I mean master send register address 0x83h so slave will send back data store 12 h to master does it happen ?

ric
Super Member
• Total Posts : 26942
• Reward points : 0
• Joined: 2003/11/07 12:41:26
• Location: Australia, Melbourne
• Status: online
+1 (1)
mukesh12
Master send only device register 0x83h to read data byte 12h from slave. I do not understand how we get 12h.
When master send register to slave, does slave send data store at that address to master. I mean master send register address 0x83h so slave will send back data store 12 h to master does it happen ?

Did you read my post at all? I went through the whole process.
The datasheet for whatever device it is that you want to talk to should also describe this in detail.

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!