Hello.
Welcome back.
In this lesson, we are going to see a much more practical assembly example with the cube.
And what we're going to do is write a GP.
I drive by using just assembly code.
We are just going to go to the.
We're going to start off by going to the datasheet, the manual and the other document and extract the
memory addresses.
And they're now assigned symbolic names to them and then access these memory addresses or locations
using our assembly instructions and manipulate bits.
So when a critical project come over here file and then New STEM 32 project and it's going to initialize
the target selector.
And I'm going to select my board over here, SDM 32 for one one v t.
Um, estimated two for one one should be fine.
Just this.
I'll make a selection and then I'll click on next.
Next is down to oh just drag it up a bit.
You can see this is next.
And then I'll give this project a name,
g.P, I oh, underscore assembly.
OK.
GPI, your driver, oh, brother.
Well, let's just keep the name Sudar.
We have the bare metal it in assembly, but they are both bare metal.
Okay, I click next over here and then finish.
I've said no, but it's gonna open the perspective regardless.
Okay.
So I'm gonna close this.
And then, um, I'm going to come to I will call forward.
This whole project, GPL you on a school assembly.
Okay.
So this is cool.
Like we did earlier, we come to source.
We don't need any of this.
Um, I'll just delete the main.
You can delete the rest.
Actually, I think at the end we should try deleting the rest.
And let's see if it's affect our project.
It shouldn't.
But we'll delete it once we've tested it.
Um, okay.
So we said we're going to write the GPL.
Your driver's, uh, the GPL.
You, um.
Yeah.
Driver for for our board.
And we're going to use just assembly language.
We already saw this in the um in the.
I mean, depending on where you are watching this particular lesson, if you're watching this lesson
as part of the estimated 32 Cuba course, we've already seen how to write, um, the bedmate or the
Beneteau GPL, your driver, if you're watching this as part of the, um, um, the ARM Assembly course,
then perhaps the bare metal lesson once existing since then, of course, is just a bar assembly.
In a way, I would just start from scratch.
And, um, this will save us a revision if you already know some of this stuff.
But I think the differences between, um, the ARM Assembly and the, um, and the and the GCSE that
we have to take note of, that is why we have this lesson, especially the directive's some, uh.
A number of things changed with regards to the directive, uh, the directives.
That is why we are here.
Um, yeah.
So let's get started.
So we start off by we said we said we um we have to enable clock access to the port and then access
the data and direction registers to get it to to what.
Our inputs or outputs.
Okay.
Before we do that, we have to create our main dot s file.
Right.
Click.
New this one here.
The new file over here like this.
And then I'll give it a name.
Men Dot is like this.
Okay.
So we said we have to take a number of steps.
We have to enable clock.
And they will clock.
And then we're going to be talking in the early days when they will clock to Port A..
And then next we've got a search deum the mode
we say set P a five two output mode.
And then
we're right to pay five.
So these are the the things we need to do.
But there's a lot of work involved here.
Because we've got to get a dim memory addresses of each component.
So let's start with what you pay your ports.
Eight, because we need to access UPL.
You port A.
We need to, uh, because we need to access ports A for its data register.
It's more to register and um.
Yeah.
Because we need these two registered from ports.
We need to find a memory address of Port A..
To do that, we need to open one of our document.
We need to open a datasheet document.
Um, we have the data sheet and a reference manual.
So the data sheet one is the shorter one to one with about 140 pages.
So this is the, um, the datasheet.
You can just come up here and then you recognize it.
Buy this over here and the number of pages, it's grown so we can find what we're looking for.
A two page number fifty four.
This gives us the memory boundaries of the various components or simply come to our search arm.
Fifty four here.
We need to page 54.
So search 54.
Okay, so fifty four here.
Gives us the um, the register boundary addresses.
So when we search it will tell us these are the cortex M4 registers.
It says from this range is reserved.
This range is for internal power flows.
And when we come over here, GPL you a start from zero X Force.
You were two two zero zero.
So this is the base address of GPL U.
E is the base address of GPL.
So we have to keep that in mind.
I'm gonna copy this over here and then I'll bring it to our project.
I call this.
GP, are you a GP?
I owe a base.
OK.
This over here.
We don't need this other stuff.
We just need a starting position to start in point.
OK, so this is GPA.
You a base.
We would also need to get D.
We also need these HP.
Remember we have the HP.
The HP one enabled register is where we used to enable the port.
So we also need to access the HP.
The HP, the HP is part of the RCC to access HP.
You go through the RCC, even in the datasheet to Spreyton RACC underscore HP.
So whenever you see in the word, whenever you see one word underscore another, the first word or the
first characters or the first abbreviation is the base.
The underscore is the offset is the same.
The GPL you such that when we see GPL you a underscore mode register GPL you a is the base address more
drudges.
That is the offset.
So with this arrangement, each module is the base.
This is a base address and the various registers in the module serve as the offset such that we have
DGP and we have the GPL.
Your base address over here.
If we want GPL, you a data register output data REGISTE that is just an offset from this base address,
meaning we simply need to add some number to this to get the output data register.
If we want to not register is an offset from this.
We simply need to add a number to this, some number to this together.
So is the same for airport in the same way we know RACC is written, RACC underscore HP.
So if we want to get the HP address, we simply add a particular number to the RCC because the base
is RACC.
If you don't understand this explanation, please let me know in the Q&A area.
So we have to get the base addresses and then we find the offset.
So in in insane language, in bare metal embedded to see RACC, we often do RACC, HP one, HP one and
they will register like this.
And then when we're dealing with GPL, you will probably do GPI you a we we probably do a GPL you it
and then more register and then this, this that we see over here.
When we go to the reference module we see that this is written in there like this is written with the
underscore is the same thing.
When we go to the reference module we'll see that this is written in there with an underscore like this.
Right.
Where.
But more specifically, this will be written with an X to indicate that is the same is the same for
GPL.
You A, B, C, D all the way to H.
So I'm saying this bit is the base address.
This is the base address if you want to get this is just an offset from this base address.
So if you want to get this entire thing, it could be that you just take the base address of RACC plus
two RACC plus two.
It could give you RACC, HP, one enabler register in the same way.
If you want to get the address for Merge Register of GPL, you say you could put a base address of GPL,
you a plus five.
So we just add that to get the address of the mode register.
This is what I mean by Bayes address and offsets.
So I, I'll just verify for you that indeed in the datasheet to switch in this way.
And the reference manual.
Sorry.
So I'll come to our documental y here.
And this is our datasheet house, the one hundred and forty nine pages.
I'm going to go to the reference manual over here and then I'll come over here and I'll do control F
and then HP will do HP one.
And when I hit enter you see that word starts with RACC underscore.
HP.
This is for a different, a different register.
But all of them are offset from RACC.
That is why they are written that way.
If we do HP enable RACC underscore HP one enabler register.
Right.
OK.
So we have this one.
We need the RACC base.
The RCC base is already know this one.
But you can go and find it out.
So the RCC base will be this in order not to spend more time hunting all of them down.
I'll be putting some of them in.
But when there is something different.
It will get Fetcher together.
RACC Bass addresses this zero x four zero zero two three eight zero zero.
This is the RACC base.
Right.
So we've got.
Did you play you a base and then RACC base?
We basically going to be dealing with these two bases because we know we need RACC.
HP want enable register to enable clock access to G.P.A. you.
And then we need GPL you moad register and then we need GPL, your output data register to set our pin
to output and to toggled reality.
Right.
So what we have to do next is to find the offset that would give us the other registers.
So for GPL you a also for GPL, you overhear these comments.
We'll clean them later.
I'm using this as the whiteboard for GPL e.
We need we need the output data register and then we need the mode register.
So we would have to get the offsets for this.
And then for RACC.
For RACC.
We need the H h HP one.
And they will register because that's what we use to enable clock access to GPL.
You put A and all other GPL your port.
So what we have to do to get you offset is go to the datasheet puppy for A go to B reference manual.
But before we do that, I'm going to create a symbolic name to hold this number here, to create a symbolic
name.
I'll use the e q u e Q..
You see a dot dot e.
Q. You here like this?
This is a directive.
And what I want to do is I want to assign a name for this hexadecimal number.
I'm going to assign a name cheapy I o a underscore base to this hexadecimal number
such that whenever I want to fetch this hexadecimal number I simply use the name of assigned GPL you
a base.
Okay, so I'm going to do the same thing for RCC.
I'm gonna see dot EKU you here
and then I'm going to assign a name.
I'll call this RACC base RACC on the score base like this.
And then over here we know the RACC base.
We said this is it.
Okay.
Our sign, the symbolic name here like this.
This is just comment.
We don't need this.
Right.
So we've got a symbolic name for this.
Then we would have to assign a symbolic name for.
We have to do an equal you.
Q You over here for G.P.A. You know, we have to do less.
Each of you for let's do a step by step.
I'm going to see GPA, your mode offset.
We can do a symbolic name for the offset so we can see GPA you a good register offset.
So when we find the offset, we just put it here.
We'll put it on the side.
We don't have this yet, so we'll feel it.
We'll fill in the blanks and then we'll do an EKU you for GPA.
You a.
Oh, dear.
Oh, poor data register offset.
And then we don't have this, so we fill in the blank later.
And then once we have the offset of this, then we know the offsets, plus the base register gives us
the actual base register.
So we'll go ahead and do it to you.
And then now we can see G.P.A. you a mode register, the actual mode register.
And this this is simply this will be GPL you a base.
It should be GPL.
You a base over here.
Plus, keeping you a more to register offset like this.
And then once that is done, we come in.
Then we'll do an EQR you.
And then this you can you will be the um the actual GPL you a output data register.
And you know how to derive that as well is going to be this offset plus the base.
So for output data register, it's gonna be this copy.
And then we paste this over here.
But this has to change to the Otey are offset like this.
Okay.
So after this we would have all the, um, all our registers.
The register would be ready.
We would have our GPL you a mode register already GPL you a Odey are ready as well.
So we will do the same thing over here.
Over here we have we've already found our RACC base.
What we need is HP one E and our PS HP one and they were ready stubbies.
So we do it.
You, you can use, like I said, used to give a symbolic name to the hexadecimal number.
We say EKU, HP one enable offset.
We do not have the offsets yet, so we fill in the blanks later
and we know once we have the offsets, we simply add the offsets to the base, the RCC base to get RACC
underscore each one enable.
So we do dot eku you over here.
And then we we call this
RACC, HP one, and they were registered just like it is called in the arm, just like it is called
in datasheet.
And this is derived by RACC base plus HP one and they will register offset like this.
Okay.
So what we have to do is go to the arm, the reference module and find the offset of these various addresses.
Right.
So we go to the reference module to fetch the offsets.
Okay.
I go to our documents here.
We use in the reference module with the one with the pages.
So we start with HP one register offset.
So you simply search HP one E and R.
This is from the previous search we did.
So this is it.
I'll click HP one INR and I can see it gives us the offset to what here in the data sheet, the offset.
This means it's it's keeping in mind that we will be doing this type of thing.
That is why it's given us the offset.
So we simply take this offset from here.
So X three zero.
That is HP one E and our offset.
So this is your X three zero zero X three zero, right?
Is that correct?
Two X three zero.
That is correct.
Okay, so next we find the offset for our GPL.
You more to register.
So I'm going to come up here and control F to search and then.
Oh, such m o t e r mode register Malda.
Okay.
And it's Protus here of click here to jump to this place and the offset me won't register is zero x
zero zero.
Meaning is the first element is the first member.
So the offset is the same as the base address.
So no problem.
We just set it just like you said.
So X or you saw X X series.
You like this.
Now all these are offsets, the output data register offset.
There's the register we'll use to control the output.
So we search for ADR as well.
Come over here.
Oh, these are like this.
No, I have to clean first.
This doesn't exist, of course.
Oh, do ya?
Okay, so we have this G.P.A. you port data register.
Oh, do ya.
Click this and the offset to zero x one four two x one four two x one four.
So we put that over here like this.
Two X one four.
Okay, so we have this right.
So we can clean our comment.
We don't need to help make these comments again.
Enable clock.
We don't need this.
Yeah.
We don't need it.
We know what to do.
This was just to tell you what we're gonna do to remind you.
Okay.
So we can, um, put our directives.
We can, um.
We can start off by just putting some directives, the C.P.U we use in the code, take some for them
for here and then our code area is down here.
We can start our section code over here.
That section
of text over here like this.
And then once that is done, we can, um, we can create a war, a global exports.
So we'll see it go global.
And then we call this main.
And then over here would have a our main label made like this.
Okay.
I think we look good so far.
Yeah.
We know.
Missing any thing.
Okay, so this is it with got our registers.
We've assigned symbolic names to our registers and the next lesson we start.
Right.
Our subroutine to initialize the GPL U.
E.
And then to Tokyo with the LDA.
So this all the rest.
No.
See you later.
Just bear with me.
If sometimes I'm explaining too much or perhaps I'm explaining it and it's not clear enough.
You can, you know, leave it in the questions and answers area and I'll get back to you.
But this is very simple stuff.
I'll see you later.