Hello.
Welcome back.
So let's develop our you outcry over creates a bit of space over here.
I'm going to start off with our directives area
to you.
And then there's the code area is read only
we aligned
that thumb.
This the entry
we're going to export our main label right.
And
we going to start off over here on a score on a scope made and we're going to branch to fess up routine
as you tune it.
Right.
So we start off by implementing our you turn it
you turn it like this.
OK.
This was rather far away.
We just move this a bit
right.
Okay.
So we going to initialize that you add.
I'm gonna start off by pushing the link register
save the current value of the link register as it is
and then next I'm going to load a.
What you got RCC.
Register and then enable clock access to that you do load
are won
because this control
are a seat to see you at the school are just the name of the register and then or take what is in this
register and put it in our receiver like this
and then perform an operation
with no symbolic name.
You are to enable or is it you are to enable
the once that is done or right the resort report to the register.
Right.
Once we've done this okay once we've done this we can um we can enable the clock access to GPL you put
a
For those of you who are not familiar.
Yeah I'm wondering about this.
I just put a C code here in C language.
This is going to be I think this control using synapses is gonna be a source control you at just control
R C G C you UT and then all you add 0 enable this is what we type in C language to get this in bare
metal and add it to C right.
So the next thing we're going to do is it's going to enable clock access for our GPA you put a.
So I'm gonna in C language is gonna be cis control our C G C GP I O A No.
C G C GPA oh and then it becomes GPA a e n over here would perform an operation for that so I'm gonna
do a load and assembly we do load this control our CTC GPA you go ah we take what is in there and put
it into register our 0
and we perform an operation with with our GPA you a enable and we start a registered back we store the
um the resorts back into the register like this.
Okay.
So this will enable clock access which EPR puts a the next then we Queen to do is we Queen to set a
set or you pays for alternate function but before we do that we can digitally enable are where you are
to PS P is you're in Pier 1 and we're going to digitally enabled them to come over here and
I'm gonna do it see language 0 2 GPL you a digital enable register and I'm simply going to
0 to sort of write this This will correspond to the bit that uh this corresponds to the bid for GPL
you pin a and uh GPL you open one in GPL you pin zero right to so do this um in an assembly load are
one we have copy I do a d n on this call R and then we take the content put it into our 0 like this
we perform an operation of our 0 and 0 x 0 3 0 3.
Remember this is the same as this or this or this is 0 before the digits doesn't matter right.
So after we do this we write the results back store our as you are 1 like this okay.
So once that is done we can figure that you are we go to the port control register
and then we first cleared a port control field for P E 1 and P issue and then we write new values to
that field.
Okay.
So I'm going to
this let's see.
And see language.
We do it GPL U A P C T RL.
This the port control register P.S. Well it is and then what we're going to do to clear a bit.
We do.
Um no sound because.
And then to Tuesday over here and then we're going to use this hexadecimal number to clear the bit for
for what you call it for P is you and Pier 1 right.
Okay so I'm going to going to implement this and once we've cleared a bit we would need to sort of we'll
need to we need to write new bits to it.
We need to configure the P issue to p a one as you at in the port control register.
So I'm going to load the register lowered our 1 e course GPA to a P C T L on the score register and
then we're gonna take its content and put it into our 0
and then we going to clear a bit using a b c instruction then we started resort back into our 0 we cleared
a bit of what is in our 0
cleared these using this hexadecimal number and then the resources put back into our issue we could
use to appearance here if we want but I'm using our shoe.
If I use just this is the same as this.
So you need not worry so once that is done we're going to configure this uh the same bits we'll use
and the results after clearing it's going to be put here.
It's gonna point to our series so I'll see Iris you and and then I'm gonna configure
P is your MP you want us you ut is the same I've seen Iris you Iris through the third opera and it's
the destination in the case where you don't audit fed or print the second or print becomes the second
or print as well as the destination.
Right.
So this this would do this for us did we deal with the alternate function register we've not dealt with
that so I'm going to enable the alternate function register
I'm gonna put that up here I'll see GPL you a alternate function select the what we want to do over
here is set s p a zero and p a 1 to the ordinary functions so pass this here like this to do this in
assembly 0 to load R 1 GPL you a lot and a function select register take the content and put it into
Iris 0
and then perform an operation
with this and then store it back
like this okay.
Right.
So once we're done with it we can start configuring the new art to configure the U.
We start off by disabling it so we simply going to disable to you at we can just write to zero today
you control register sort of everything in the register set to zero.
We can just set a particular bit to enable disable it in the register to zero if we want to set a particular
bits to zero we have to use the M B C instruction so let's do the start off by doing load our one with
a you add control register you at zero c t o on the score R and then we're gonna take the content of
the register and put it into our 0 and then we're gonna clear it by doing b c store the result in our
zero take our 0 and then apply you to control enable which we've created a symbolic name for this one
over here.
Right.
And then we store the results.
Our 0 1 like this
next.
We configured the bot rate we're going to access the 2 bulk rate to registers the 1 for the integer
part and the fractional part.
So I'm gonna say load our 1
portray to register in the name we gave it was it should be up here somewhere.
Let's get a name
there's the first one you at I P R T R This is the integer portraits register
we load this first and then and then um and then we compute the bulk rate so to to the broke rate we
have to divide our clock frequency by 16 multiplied by the board rate we want to use remember popular
but rates that we often use include
popular board rates include nine thousand six hundred one one five two hundred etc..
So to compute the value to put into the box rate in which I register the formula is to take our clock
frequency the frequency of my MCU is sixteen figureheads mean 16 million or take this 16 million and
then I would divide by sixteen multiplied by the portrait I want to use let's say I want a board rate
of one thousand and fifteen one thousand fifteen and two hundred sorry one hundred and fifteen thousand
two hundred let's say I want to board rate of one hundred fifteen thousand two hundred I'm going to
compute this I'm going to do sixteen million divided by sixteen times one hundred and fifteen two hundred
if I want this out put this here if I want a portrait of nine thousand six hundred multiply this system
by this if my frequency is different.
Leslie I'm running at fifty megaHertz I'll have to change the sixteen to fifty two how fifty million.
But I'm run the sixteen megahertz This is a constant.
So these are the two variables right.
And when I compute this one you perform this calculation you get eight point six eight 0.
So this is going to be the answer.
This is the integer the integer between is 8.
So we've got to take this 8 and put it into the integer both to register.
Right.
So what I'm going to do is move this to the to the register so I'm going to do I'm simply going to use
the M the move instruction to achieve this oh do move move are zero the number eight and then I'll star
it into the integer portraits register by doing so what is an ask you are 1 like this.
Okay so now we've sorted out we've put just this eight How about a fraction politics it's not complete
we're going to store a fraction part in the fraction register so I'm going to load that
I'm going to do load R one equals
you 0 F R D fraction board rate is F B T.
Yeah on a school R and to compare it to the fraction part we'll use a different formula we take the
French we take the this part here plus fractional number we multiply by sixty four and then zero point
five.
So we took what is left here that is gonna be
this is going to be zero point six it's u of five multiplied by sixty four multiplied by zero point
five and the answer we'll get to be forty four point zero five two.
So this time we just take this as well we don't care about this last bit is fine so we're going to move
forty four into register our zero
and then we're going to store it.
Right.
So once this is done we have to set our um our wetlands.
They pay to land.
We want to use and we do it is by access the line control register.
So I do know these are our one.
I want a course you zero LC RH on a score are for register and then I'm going to do Delta.
Ah I wish you would take the content and put into our receiver like this and then once we have that
we're going to we're going to disable.
We're going to clear all fields.
Now we can do B C over here b c are as you are as you f f
and once we've done that now we can set the with as well as enable.
So I'm going to do at our zero end.
Are you sorry and our zero hours zero
and I'm going to get the symbolic name we've created here.
I'll get this
and then I'll include FIFO and naval as well.
I'll get Fi for a.
This one here.
Bring it over here like this.
Once that is done we can still use the stone instruction as the are r zero
R 1.
Okay.
So finally all we have to do is enable it to you at because we disabled it when we start it.
So we accessed the control register.
Oh these are our one you at zero CTA L on the score.
And then we move the content into register.
Iris you were like this.
And then with the form 1.
Operation
we created a symbolic name called U UT c t o u s e n.
Right.
And then we can store our 0
r 1.
OK.
So because we pushed the link register when we started we've got a pop it gonna pop.
LA um.
Got it.
I'm going to
I'm gonna pop the LR here.
Let's see.
Yeah.
Okay so this is going to be uh.
There's gonna be a uh you out initialization subroutine.
So the next thing we've got to do is create other subroutines for um for reading and write and data.
Okay.
So let's do that in the next lesson.