Hello.
Welcome back.
So let's implement a what you call your driver.
So I'm gonna start with the um the directives.
Um for those of you who don't know there is a prerequisite for this course before you take this course
I expect you to take the um the um arm assembly program it from ground up of course and in that course
we went through the instructions step by step the directives step by step we'll explain everything.
So over here.
Yeah I'm not gonna be explaining the instructions under directives much I'm just going to I'll be demonstrating
how we use those instructions and directives to write usable um drivers for our microcontroller board.
So for those of you who haven't taken that course I would suggest you stop this course and then give
you the first few lessons.
Up to the point where you um you view the lessons on directives and instructions and then you can continue
here.
You can send me a message I'm gonna send you a coupon for that you need.
No you know buy it at it's expensive price.
Um so I'm gonna start off by using the area directive
text and this the code area is read only
gonna align to
it firm over here.
This the entry and then I'm gonna export
on it's gonna escort me like this is gonna school me and I'm gonna start off by enabling I'm gonna start
off by branch into a subroutine to enable our GPL you call this GPL you in it and then let's implement
GPL your niche no GPL you underscore in it.
So we start off by enabling the clock access for Port Pete.
If we had to write this in bare metal embedded C using CRM says R2 says control like this
and then our C GC GPL you and then I'll use this I'll put a vertical sign for all and then I'll take
the symbolic name we create it.
Right.
And this would enable clock access to port C this is a comment right in assembly.
So this is what we're going to implement.
So to do that we need to load the address of this GPL u r c GC GPL you I'll say load
our 1 equals we have the address here
and then I'm going to load take basically to use this in plain language what this is I'm gonna see take
our issue out to take um.
So basically this means take take the content of it.
How do I put this in plain language.
Take the content of what is located at at any one input into our view.
So something is located at r 1.
All I want is pointing to something.
Take the content of what our one is pointing to and put into our series.
So in effect we take the content of the current content of system control RC GC GPL you register input
into our 0 I'm gonna perform an operation of that.
When I say Oh Iris you are 0 and then GPL you enable.
So so after that after this line what is in this register is gonna be put in R2.
So we're gonna take what is an Irish U.
And then we perform an operation would you call you f enable.
Which is the symbolic name we created here.
I store it back into our Sera.
We can use to operations if we use to operations.
It means that resort.
This is the source number two as well as the destination.
So we can keep it like this and it's gonna be stored in our ship.
Right.
Once this is that is done.
Meaning we've modified what is an Irish you don't know we can write the new contents of Irish you at
the location of this register in effect at the location of this um um at the location of this address.
The reason why when I see red is that I always freeze is that we've got registers Irish who are 1 are
two or three and business are registered to.
But when I say this reg is that are you thinking there's any cortex is it.
Um is it the system going through our GC register.
Or is it the register in the register bank such as Irish you are one.
So what I do is oh endeavor to call these addresses or although the outrageous this or refer to them
at as this address read them register that to limit confusion.
Anyway if you if at any given point you you have a question just send me a message.
I don't know how this is going thus far.
Cos I keep explaining random stuff by should you find yourself confuse the boy a little thin.
You can send me a message.
Um.
Right.
So we going to use this for instruction.
I'm gonna say you stole the source.
I just ask you.
And then I have one here.
So after this we would have executed this.
Right.
And we can allow some time to finish activating by using the new operation A.P. A.P. A.P. this would
just allow some time it's like Yeah wait a bit.
Okay.
So now the next thing to do would be to set up a whopping to output pin a red pin red over here.
We need to set it as output and we do that by accessing the display of direction register.
So in C language how do you spell you f desire.
And then I'm going to say 0 x
0 2.
I'm gonna do this but we've already created a symbolic name for 0 extra 2.
I should point out 0 0 2 is the same US is the same as um is the same as this.
Why do I say that.
Cos if I explain this you were X 0 2 to it s binary form 0 end up with 0 b 1 2 3 4.
And then one two one zero.
Right.
So this 0 this hexadecimal 0 does.
Sorry about that.
This hexadecimal 0 corresponds to this for binary zeros.
This 2 in binary form will give us this uh this 2.
Yeah.
If we convert it to binary 4 bits binary does what we get.
So this is the same US shift uh shift in one at position number one to number one.
So this is bits numbers zero a bit to number one.
So if I do this I'm saying shift 1 2 bits.
Number 1 which is the same as having this which is the same as having this in hexadecimal code right.
And we gave a symbolic name to this.
This shift one at the position number 1 we call that OLED red.
So I'm gonna copy LCD red and put it here like this.
Um
I'm gonna see like this I'm just gonna over come into this okay.
Right as the course goes on I'm gonna reduce the amount of comments I use.
Okay so this is the C language estimate and assembly.
I'm gonna say load R 1 GPL u f D.A. R register and then load r 0
are 1 and then I'm gonna perform all
o r as you are sure I can use a single upper hand over here I had to bring the number sine sorry I'll
let you read then I can write a book by using the store operating.
Oh operator store the store instruction I should say store like this.
Okay.
Now we have set this as output
I'll put more comment here.
Set p f 1 as output.
What we just did.
Enable clock
access to port F right.
That's what we did here.
Now we're going to
digitally enable Pier One so to do this and see language oh would do chippy i o f d end for digital
and they would register.
No I'm simply going to do this early do read again I'm right and the same thing but this time to the
digital enabled register.
Right.
So in assembly language how well you cried.
Could you post a video and try to enable this in assembly language you can look about what we did over
here and over here.
Right.
So once you write down we can do it together.
I'm gonna do.
Load
one course GPA F D E N R and then load are sure I run and then O R Syria a lady red and then store our
0 R1.
Once that is done we are done with this subroutine we can return from the subroutine by using the B
X L are like this okay.
Right.
So now we are done.
Next less write a subroutine to turn on the LCD.
I'm going to call this early on.
Come over here and have sorry for the lady on over here and then we start off by loading the data register.
Remember to turn it on we need to write 1 2 the P F two P F one of the data register of port F and because
the LCD connector there when we write one that the LCD in effect will be turned on so I'm going to show
you how to do this C language GP I o f data and then um thus we can use friendly programming again is
simply right in additive red I think.
Yeah.
Okay.
So I'm gonna do load.
I'm going to load the address.
I have a typo here.
There should be d I.
Ah okay.
So GPL you f data from the school are
and then
this is going to be a simple move.
Oh do you move into register.
Are you do you read and then store it
and then be X a la and then a line and then end.
Right.
Okay.
We look good.
So what I'm gonna do is I'm going to call this subroutine as well.
So we start off by enabling our what she you.
Once we've done that we're going to branch to turn on the entity and then we're going to create a loop
by branch in by branch into the top over here.
Be such that after we turn on the LCD and we execute this next line it's going to take us back to the
top.
Back to the top.
We come back.
We turn on the LCD.
This is going to take us back to the top.
In effect this is our wall one loop.
So now let's test well we have right.
So I'm going to set up my debugger or come to target options over here under debug dropdown still areas
ICD I CDI click on settings and then I'm going to click reset to run.
Okay.
And then okay and then I'm going to click here to build up here.
It's built successfully.
Click here to download onto my board.
It's downloaded and my Elegy is not on let's see
um.
Let's let's check our code from the top.
Um I think the reason this the reason the LCD or Blinken is from the source that base the system control
base address here I'm skeptical about this address.
Let's go to the data sheet and um see um.
Come over here.
I'm gonna search.
I'm gonna search system control base address and then um it's a problem here.
You can stuff from the top.
I simply type system control base address and then is promo here.
Register map as the offset listed as Exodus more increment to the registers relative to the system control
base address.
So it says this is the base address of the system control.
So I'm gonna use this is that I'm gonna copy this and I'm gonna search more and see what this is that
persistent piece that tries given to system control base address over here.
It talks about system control registered description all addresses given their relative to system control
base address and thus the system control base address and range that's provided for legacy software
support.
Okay so it's the same address we saw earlier.
Right.
Okay.
It's the same thing right.
Right.
So this indeed the system control base address I'm gonna use that.
So yeah.
Taking the system control base upgrades from the RCC base address won't work.
Yeah.
Sometimes they are such nuances and with experience you would know what to look for.
Okay.
So now let's try.
Um I'm going to click here to build Click here to download onto my board and it's download it right.
If you have any questions just let me know and I'll see you in the next lesson.