Hello.
Welcome back.
So in this section we're going to look at how to generate standard general purpose input output firmware
code using the SDM that's to cube emacs in this very first lesson.
We're going to generate code to give us a simple input output effect.
We're going to initialize an input pin and then an output pin and then you're going to see how easy
and how very straightforward it is.
Before we do that let's take our particular board.
I'm using the SDM 32 F4 disco board.
So what I want is I want to take a look at the user guide and see where my my user button is connected.
My Disco Ball comes with one use a button and for ladies.
So I want to know which particular GPA your pins.
These are connected so I can just generate that initiation code for such pins.
To do that I'm just going to search the name of my disco board.
I'm going to search it on Google.
So you search this on Google the name of your board.
Plus the word user manual and you find a link to the PDA file and then once you do that you can just
scroll down to this schematic diagram.
I'm just going to come down here and I should see a schematic somewhere yes OK I just assume in and
as we can see over here my L.D. I've got my got my green LG connected to PD twelve my orange connected
to PD 13 the red to 14 and the blue to 15.
So I know these are the LCD pins.
Next let's see where my use a button is connected.
Let's see.
So here it is says user in Wake Up button so we can use.
They use a button as a wake up button as well and it's connected to a zero.
So what we want is to go to Cuba next and enable P is you as a digital input and then enable one LCD
over here.
How about we use the orange which is which is PD 13 as a digital output.
And then we just generate code for that.
So let's head to Cuba Amex and demonstrate the I've just opened my Cuban Amex from here and I'm going
to create a new project.
And of course you will bring me here.
And what I want is to select my board our youth sports selector over here and I want a discovery board
so that discovery over here my MCU is the SDM 32 F for MCU and the particular microcontroller version
is the 4 1 1 e so select this and then I'll double click and I'll just expand here like this and it
gives the pin out.
Yes.
So first step what we want to do is to disable the forward to pin out.
It's provided us so I'll come over here.
Pin out like this and it would ask me and then I'll confirm by clicking yes.
Once that is done we said why are our button is connected to a zero and we want to use the orange LCD
which is connected to PD 13 so I can just come over here click this and then set it aside GPI outputs
like this and p zero.
Whereas PSU we can search PSU here p zero and here it is I can click this and set it to a cheap I O
inputs and I can rename this label like we learned by right click and enter and I just call this orange
and I call rename this also by right clicking and to use a label and I'll call it button like this.
So once this is done we want to come to clock configuration and we can keep the default system clock
which is ninety six megahertz that's good.
And actually we have to set the debugger we have to set this as y s the system settings we have to choose
otherwise we wouldn't be able to program our microcontroller board and so I'm going to choose the serial
wire that's what the disco board comes with our select 0 wire here and of course in the data sheet we
realize the p A's euro can be used as a use a button or as a wake up button.
So because we use it as a use a button we've caught a red market indicate and there is a conflict we
cannot use it as a wake up button but we do not need a wake up button anyway so that is fine.
So I just come to configuration and we don't need to configure anything for this project and I'll come
to generation I'll click over her project folder choose this folder and project name or call it input
output imposed on the school output and coach generation on leave all of this the same and I select
my my to change which is the.
The five I select this and once that is done I just click okay to generate the code
and I just open the project open the project straight up and later on I can come in.
Click here to generate a report for my or my particular project.
So let's see it's generated.
We can open here to inspect the main file and here we are it's generated although we need it's initialize
the GPL use and we can expected by double click and right click go to definition and before we get everything
to link up we have to reduce the project.
So I'll just rebuilt this
and it's finished rebuild and now I can right click and go to definition and let's see how it's initialized.
It's initialized GPA you a.
This is where our pattern is connected.
It's initialized GPA D as well where our lady is connected and this the initialization sequence.
Those of you familiar with program in the SDM 32 hardware abstraction layer this looks very familiar
to you.
So the label we gave it's orange it's it's said the label name here us orange pin and the other label
we give the button nice button is said to her as a button pin.
So without much ado I would just go ahead and beating around the bush.
Let's just demonstrate.
So what we want is to read the button and then write the value of the button to the LCD.
What I'm going to do is I'm going to go inside my main file.
My main function to do this of course initialization here and what I want is if I'm not very familiar
with the API is to use at this stage I can always click functions over here and select the particular
module I'm looking for which is the key API module.
And once I click here it gives me the list of functions and that's the function I want I want the whole
GPI or read pin.
This will allow me to read a pen.
So if I want to see more about this I can double click this function and then it tells me about this
function.
This function takes two arguments the port and then the PIN number.
So in fact if I don't want to type it all I can just copy this function over here and come to Main and
then paste it and the pin I want to read is and GPI you GPI.
Okay.
And it pins zero P I O pin zero like this so I can read this and this and this function returns a parameter
returns the port pin value the value of the pin.
So it's returns it as 0 or 1 0 means the penis or President 1 means it is pressed so I could just come
here and say declare new variable here.
You in 32 button status in 32 underscore t you in third to underscore t button status and I could I
can come down here and see a button status a course this
and what I want is I can just write the value of button status to the to the LCD I could just come here
and see how GPI your right pin all on the school GPA you score right Ben and this one also takes the
port's name GPA D and then a pin number GPA I could just say orange pin because of the label we used
Yeah we could have used button pin and then I can just see buttons state status like this just to demonstrate
I I'll just call this button pin here like this and you can see the useful ness of the label here.
So now it's all set.
Well we have to do this with Dillard and then download onto our board and I'll just rebuild from her
and we can verify the box settings here as you can see debugger is the SD link debugger using the serial
wire and we can verify that from her.
I just want to reset and run so I don't need to press the reset button to see the changes take effect
so I'll take this over here and click okay and click okay and I reviewed my project and then I download
onto my board and it's finished downloading it's running now and I can see as I press the button the
light turns on.
So this is very simple in fact if you've never program an SDM 32 board before just by using the Cuban
mix you can get this to work in less than two minutes basically.
So let's move on and see the other application I'll see in the next lesson.