Hello.
Welcome back.
So we still need general purpose input output section and in this lesson we're going to demonstrate
how to create an external input interrupt function using the and 132 cubit next.
Well we want to do it.
We want to see the interrupt lines connected to the various GPO pins and we can find that from the reference
the reference module of the estimate that the microcontroller.
And this time we don't need to go to Google to look for a cause call your vision has assembled the books
here.
I could just come over here and go to the reference module.
This particular book double click to open and once it opens I can search extend or interrupt again it
is extend or interrupt slash defense control of this what we're looking for.
It's on this page here one hundred and ninety eight.
Or just click it.
And then what I want is down here.
I just want to see which interrupts line my push button is connected to.
So as we can see P A zero is connected to extend interrupts line zero.
And if we want to use a different pin for extend or interrupt we have the option is to use to zero pieces
you APD you use your X etc..
So what we need to program is to extend all interrupt lines here.
That's good.
And we already know where our LCD is connected.
So we have all we need to go to Cuba makes to create a new projects to demonstrate this.
So let's head to Cuba next.
Now this is our own project.
And what I'm going to do is I'm just going to create a new project or just minimize all of this this
creates a new project from here.
You project and I'm still using the same boat as the estimate.
That's a two disco board by microcontrollers to the same double click this office cleaned up paints
by just going to clamping out.
Yes.
And this time I want to activate PD to us extend or interrupt like this.
And then we still use our PD 13.
So keep your output to two lights up our entity and let's get another entity for this project.
I'll just use this one here.
I don't know which color.
This is but I'll just use it and I'm not going to change the label so I'm just going to keep them.
Remember them later.
And yes this is all there is to it.
And we have to settle on debugger or just select the zero Y overhead and it's initialized for me.
Next I can I can leave the configuration to the default settings and over here.
Now we have to configure to interrupt what we want to do is click the ethic and select the interrupt
we use in the external interrupts lines here.
So we just have to take this one here and that's all there is to it.
And then I click OK next i click over here to generate my code and I give my project a name call it
extend or interrupt external on the school interrupt and I'm using the call and decoded version 5 and
I leave everything else the same I click OK
it generates it then once it's done I click open project
and once this is done I can just expand this and take a look at this.
And to bind everything together I'll just rebuild the project
so this time what we want is we want to keep our orange LCD on at all times and we can put that in the
infinite loop here.
I can come over here and see Hall GPI.
All right.
And I could just give the ports no cheaper imports D.
And GPI you 10 13
and I could just write it to one.
We initialize them just go and verify this quickly pan out.
So we have 12 and 13.
So let's just keep the entity connected to pin twelve on all the time and let's still control the orange
energy use in our push button.
So when I compile this we are just going to see that one end to be on this reboot and in fact you can
verify which entity it is from the user guide.
And once that is done building it can reset and I can see that green entity is on.
So we want to keep the green energy on at all times and we can have our of our button 10 on the the
orange LRT and we can do this in the interrupt.
So what we want is to use interrupts to do this.
So we have to populate the interrupt callback function to do that.
Let's just assume I don't remember the nature of the function cyclic functions that come overhead.
I select this particular module the GPI and then I expanded and it should tell me over here how it you
tell you extend an interrupt and it should give me the external interrupt.
So this what I need to extend or interrupt callback so I can I have to edit this function by put in
the code I want to execute when to interrupt OK is inside this function without using this key word
weak key word here.
This week key word means you can redefine the function.
You can customize it.
And the next time the compiler is looking for that particular function you would use the function you
have defined without the weak keyword.
So what I want is I just want to paste up function here and clean this here.
And in fact I don't even need to read the pin I don't need to write the code to read the pain because
as soon as the pen is pressed the interrupt to interrupt to detect the presence of the pin.
So all I want to do is turn on the entity here so I can see how and I'm sure some of you are familiar
with interrupt already rights being GPL Hootie API you pin 13 and that's all there is to it.
And I just write to high class argument so I can build head and I'll just enable the reset and run option
by ticking like this.
Okay.
And then.
Okay then I'll download onto my boat and it's finished downloading.
And as you can see it credibility entity is on when I press this the instructive case the audience goes
on and I didn't put in a code to turn it back off.
So this is what we expect.
You can toggle here or you can do it in a form of computation here in.