I2C

A free video tutorial from Augmented Startups
M(Eng) AI Instructor 100k+ Subs on YouTube & 60k+ students
21 courses
56,752 students
Lecture description
Fun and Easy I2C - How I2C Protocol Works
This video gives you an introduction on how I2c or the two wire interface works on a fundamental bit bang signal level. Watch this lecture if you want to understand how I2C works before you implement it on an Arduino.
Learn more from the full course
Fun & Easy Embedded Microcontroller Communication Protocols
Learn the Fundamental Theory of Embedded Microcontroller Communication Protocols for Arduino and FPGA
01:17:42 of on-demand video • Updated February 2017
Understand the fundamentals of Transmitting bits to other devices
Able to differentiate between the various serial protocol and decide which protocol is the best to use for a given application
English [Auto]
Hey guys in this league should begin teaching you about ice squared. See. So let's take a look at what I could see its say out to transfer a bit of data say 1 0 1 0 1 0 0 in hexadecimal. It can be 0 x 8. So I'm also want to transfer it to the slave. We can do this by having a clock line which clocks in our data and then we have 8 bits of data. So but zero to put 7. Now as you can see consumes a lot of bins and it may be quick because you have been able to transfer what you want to minimize amount of pins that you have. And by using this scheme you can easily transfer 8 bits of data. Now what if you wanted to send more than 8 bits. And also we have a physical constraint in putting on a lot of bins by using amount of payroll data. So to counter this we use could see which is created by Philips so ask assistance for the integrated circuit. That's why they call it. I see or I see. So how it works is that you got a clock line and you've got to draw a line. And these are basically put up resistance calls are on and are Soviet. They know that too deep into the vault or files depending on the voltage levels of the master slave so that what's good about the can see is that you can have up to a hundred and twenty eight device on the same bus. So I can have multiple masters or I can have multiple slaves all in one bus and all this happens while saving an open space open allocations. So now we can send our data to any one of these devices. So these devices can either be I can add we know they can be an accelerometer temperature sensor from memory or an older display they can be a variety of peripherals on the same bus. And this makes I can really fast and flexible. So let's look at how it works. So we start off with those tarpit So stuff that goes from the master the slave and it usually looks like that's where you got your data line which is SD and it goes on first before your clock your clock that goes on a bit later. And that signifies a start but you a slave nexus and the control right now the control box is also known as the device address so we send the device address so no matter how many devices we have we can always identify which device you want to switch. So the device that we are using is the microchip 2 4 3 2 5 6. Now this device has an address of hecks 50 or 1 0 1 0 0 0 0. And that's what he sent you sending a 1 0 1 0 0 0. And the data signal usually goes up straight after the start but so when the clock is high then be entered in our data bit. And over here we break it to zero. And and so on and so forth. Another thing what I could see is that you can either have a 7 bit address or you can have it 10 digits to 10 but it just can't have do one or two 4 devices. The same bus which makes it really awesome. So not for this device the first four bits are fixed so the 1 0 1 is fixed these ones. 8 8 1 and 0. These ones are physical pins on your chip. So these ones can be set by placing them high or low depending on what address you want to set. So there's a limited amount of EPROMs that you can put of the same device on one could see us next. After that comes out right. But so he said No really. But this tells the device that you want to either read or write from the device. A zero signifies right. It one signifies read next. After we sent our first bunch of data all levels was done saying we acknowledged it and then acknowledged but the master and the muscle see OK we have communications with us live and thus we can proceed to the next bit of data. So as you can see a zero easy knowledge in the net is it one or not or not knowledge. So looking at a data sheet of that device we already mentioned that we got to stop at 1 0 1 0 and we put in our address but as 0 0 0 and then we said 0 because we want to write to the device. Next we're going to send that. Yes. Right. So over here we have the most significant and the least significant byte. And then we send out data. Now over here we have a 15 but address with Avia it could be 16 but this is don't care. So if dictu to the 15 we have around about 32 kilobytes of data that we can write to this device that's 32 times 8 bits. So if it was in our district is that right. So you send out a address register. This is the address of where we are and write our data to. So we don't write our data to address one. So how do we do that this is extra It doesn't matter if it's 0 or 1 and it has in zeros trot the thing. And then we proceed with the least significant bit we should make this but one this year signifies an address of one day after we send our data. Now we want to send our data is 1 0 1 0 1 0. We saw the most significant bit as the 7 0 is highly significant but. And we had to send it in this order. And just remember after each bite within the slate since it acknowledged to our master and then finally we send our stop but also known as a post but we are finished with our transaction and now you can go into idle state and outlaid will stay in that state until we give it another start but where we start our transaction all over again. So what is fun to read. Looking at the data sheet we do the same process but is the data. So we bring out a device that. You said that we're going to. Right. We're going to overdress and then started again since I stopped. But now we put a one over here which signifies a read now because you sent out a address by before you can now proceed to read Ardita and this will come from a slave to the master and once it's done we send in not acknowledge and then he send the boss but Or stop. And then we send a stop or pause but. So let's look at the code. This is the code that you can use for the Adreno. And this is to communicate with the eeprom which is the 2 7 0 LC 2 5 6 chip. So we set our devices just as 0 5 0 which is hexadecimal 50. And we went right to the eeprom. You're right I would suggest that just location that you to to or just be set at zero for the moment and then we send our data which is X or Hecht's AAA which is 1 0 1 0 1 0 1 0. And using the same process we are right or device address shift outputs so that it includes our address we send our data and then we end our transmission most of the stuff that we sent is incorporated in the wine library which is also known as the eye could see library but they call it the wine library. And the same thing for the read from the from device address and using the why is that request form. We can get our data from our eyes could see us over here. It's as if our eyes could see what is available. We want to write our received data to our data and then we return our data. It's quite simple and very easy to read and write from our from. OK so that is it for this election. I've seen the next video. And please don't forget to like Skype share and comment and I'll see you next to you. Thank you for watching.