Hello, everyone.
In this lecture, let us build a digital clock using our microcontroller pick 16 of eight seven eight.
So for this, we are just going to interface this one three zero seven.
The other thing I see to our microcontroller pick 16 of eight W7.
Let's get started.
So this I see that as one three zero seven is using I2C bus, so we just want to confiscate the I2C
bus off of a microcontroller for communicating with the.
So in this lecture, let's see some of the programming sequence for.
Establishing agency communication in our microcontroller.
So the steps involved in.
Interfacing the space wanted digital sovereign with total microcontrollers.
Initially, there are separate registers that is allocated and there's one three zero seven one is four
seconds minutes previous this month on you.
So in the first step, we will be writing the corresponding registers of bias one three zero seven Battiste.
We will be writing in the first step.
We will be writing the values for the registers that is allocated in this one three zero seven.
That we will be writing the second value.
We value our value being value month value on year value.
Once the data is successfully returned to the allocated registers, at least one zero seven, our only
job is to read the values from the same registers that we have written to the biggest one three zero
seven that we will be doing in the writing process in our program.
So that is the second step.
Read from the distance of bias one three zero seven.
Once the data is read, we will be printing the ballots to the LCD character, to the big microcontroller.
So the programming sequence outlines that we are going to see in the selected us.
We are just going to see how we can drive to the APC bus and how we can read from the I2C bus and the
programming sequence for Starboard Starboard.
Let me start with acknowledgment and not acknowledgment, but are the sequences that we are going to
see.
So this program sequence I specially meant for establishing to see communication in our peak microcontroller.
So this is not specifically meant for this one three zero seven.
This is meant for devices that is using AI to see communications, so you can use this programming lens
while interfacing any devices that is using AI to see communication.
Not only this one three zero seven.
For the first two sequences, Starboard, so using these three lines, you can establish a starboard
from our big 16 of eight double 17, that is.
Firstly, we will be setting the yasay, and that is the start, it will be from the yes, I speak on
to register.
You can see.
Can see this is.
You seeing, but is available in the U.S. to speak on to register.
This is a data set of the microcontroller.
You can find this data download section of this video link is provided.
And this is stark condition enable, but if this is initiated, this will initiate the if this is set,
this will initiate this dark condition of the I2C bus and you can see this line.
It is automatically cleared by the hardware.
So that is why you can see we are waiting for this bill to be cleared by the hardware.
So this will look will hold the control until the scene is slow, one step too slow.
That means they start but established.
So we are moving to the next lane and we are clearing the SSP.
Eye your flag from the Pavon register.
So about this flag, you can see.
That is available in the play, Arvin registered.
So this is sinking on a cereal put into a flag, so these are some of the conditions at which this flag
will be raised.
The can see.
You can see this flag will be raised when the start condition was completed by this ISP model, and
it will be restored when this top condition is completed.
And also when the restart condition is completed and acknowledgement condition is also completed.
This flag, this flag will be raised, so we are clearing that flag.
So using these three programming lines, you can establish or implement start, but from over.
Microcontroller to the I2C bus.
So for establishing stop it, we will be using the similar procedure, except one thing that is we are
setting we begin with from the U.S. speaking to registered.
After a similar case for Starboard, the species is meant for its top condition enabled, but so this
will initiate the stop condition and it is automatically cleared by the heart of it.
So we are waiting for the pin to go low.
Once it is enabled, then we are clearing the it's flag.
So for establishing repeat and start the process the same, we are setting the artist Ian Bit from the
to speak on to register to see the list repeated start conditioning enabled.
But we are setting the split and this is also automatically cleared by hardware.
So we will wait for this bit to go low once after we are setting this.
And once it is gone low, we will clear this up your flag from the P.A. Avent Register.
And we have seen the repeated start now we will go for the acknowledgement, but for sending an acknowledgement,
but we will clear the U.S. bp bit from a suspect gone to register and we will enable the yes gain bit
from the yes I speak on to register.
You can see.
This is the acknowledgement data, but.
And this is the acknowledgement sequence enabled.
So for sending an acknowledgement, we must enable this indication.
And this is also automatically cleared by the hardware, as you can see.
So we will wait for this bit to go low once it's enabled.
So once the acknowledgement is properly sent, this will be automatically cleared.
So we will be waiting for this.
But once it is enabled, using why look, and once this witness said we will be deciding whether to
send an acknowledgement or not, acknowledgement using this is security.
That is, if you are upsetting the spirit, then not acknowledgment dissent.
And if you are clearing the acknowledgement assent.
So for sending an acknowledgement, we will clear this.
But.
And we will wait for this is a game, and you can clearly assess your flag also, but no need to do
that while you are sending acknowledgement for it and for sending the note acknowledgement.
The process is same, except that we will set the the security bit from the it's speak register.
As I said before, if it is one, then not acknowledgement is sent.
Except that the programming sequence lanes are similar to acknowledgment, but as you can see this.
And that is all about the.
Initial programming sequences, and we will go for the right data sequence.
I know we will assume that we are writing a date of zero zero for two the I2C bus and this next line,
we will wait for the suspect a flag to.
Go hit the test once the data is successfully loaded to the I2C bus.
This flag will be raised automatically, so we are waiting for that and we are clearing that bit.
And after that, we are taking a condition that you are taking the easy care.
Yes.
That is the acknowledgement status from the it's a second to register you for this.
Hey, we are stopping the process that we are sending these dog, but we will see what is the acknowledgement
status.
So this is not a demand status, but you can see.
Whenever we send that data.
In an I2C bus or whenever a monster census data in I2C bus, it will receive an acknowledgement by this
disclaimer this we saw in the last I2C working letter, right?
So if this is one that means acknowledgement must not proceed from the sleep.
And this book is zero and the acknowledgement is received from this level.
So you're taking for this, but in the SSP control register in for this one.
That means the slave was not responded with the acknowledgment signal.
So we are stopping the process.
You can see these 3-D programming sequence for Stop, but.
So that's it for right comparison and for reading the data from the I2C bus, we are just going to implement
only three lines that this we are enabling the RC ion from the to speak on to the distant.
This offseason is nothing but the receipt, and it will be four a.m. So we are enabling this bit and
we are waiting for the beef bit from the Zespri start register to go right?
Put this height.
That means the data before of the I2C bus is filled with data.
So after that, we are loading the data to that variable called value.
So it's a speed buffers buffer register for holding the I2C data.
So we are loading the data that is present in the SSP above to the variable called value.
So that's a body programming sequence for implementing I2C bus in order microcontroller look, 16 of
edible, so.
You will see in the next lecture.