Hello.
Welcome back.
So in the previous lesson we saw how to configure and detect GPI.
You interrupt and we used GPI report F and we were able to execute what was in the GPI you put f interrupt
handler whenever it switch one or switch to is pressed.
But I suppose that left you wondering how do we differentiate switch one from switch two since we were
using the same interrupt handler for that.
What if we want a different set of instructions to execute when it's a switch one and then another different
set for switch to how do we do that given that both of them are connected to port F and we've got just
one port f interrupt request handler so we're going to show that in this lesson I'm going to create
a copy of the last project and I'll paste this copy here and then rename it to version 2 and then we
continue from there.
Port underscore fee 2 Over here then I'm going to open this and I'm going to close this project then
I'm going to open fee 2 and then I'll open from here
right.
So this our previous projects and we've got GPL you put F over here aren't we totally into green LCD.
Three times when the GPL you put a forecast in this case when we press any of these switches we have
on our team that to our seaboard.
Now what we're going to do is we're going to let one switch target with a red LCD and another one is
toggle the green one.
So currently we are totally in the red already in the infinite while one loop.
I'm going to delete that so that there'll be nothing happening in a while one loop is just going to
be empty
like this and to detect which interrupt or cared we're going to use an if and check the Empire's register
to see whether the interrupt is from pin for or pin 0.
So let's do that now.
I'm going to come up here.
I'm going to just bring it here because we need what is up here.
So we're going to start by saying well GPL you f minus
is not equal to zero.
Then we open this block and then we'll check if it is.
Which one by saying if you call your f am I s
and you're X once you're
if this is the case then we're going to target with the.
I'm just going to fudge this code over here to target the green entity gonna fetch all of this actually
all of this screen to be fetched
and pasted in here so if this is the case wanted to go the green LCD three times right.
So we have to come out here and do.
Else if
you play your f m s and sure of X through one and this chick this is chick
chick if esta Picchu which is PFC PSU if that's the case I'm going to paste this I'm going to change
it to be the red LCD and we have to do is change this to 0 2 over here and shoot you over here right.
Often the interrupt should should should.
CLAIRE Well with Claire it and when we read back.
But if all of this doesn't make sure the interrupt is Claire we've got to force it to Claire and to
do that.
I'm gonna come over here and say.
Else open a block here and see GPI you f I see are you cause you f m my ass.
And we do read back because you play F I see ya.
Right.
So now we should be able to execute we should be able to execute based on the.
We should be able to execute different instructions based on the um the pin so this block here
is for switch one and this other block here for switch to CODIS PSU ISO
PFC or ISIS touch here
right.
So like I said we're just using the utilities as examples here.
Right.
So let's build and see how it looks.
Click here to build let's get it on our board.
Right.
So before we download onto our board we first need to enable global interrupt.
Over here we disabled interrupt globally and we've got to enable interrupt back in order to be able
to interrupt.
So C enable our over here.
And once that is done are revealed by clicking over here
and click here to download onto the board.
And once that's done we can see.
So this our board.
Now there is no LCD blinking at all.
And we said we should blink the LCD when once we should blink the LCD based on the interrupt that occurs
and with attached interrupt to our switch zero and switch one.
So if I press the switch you can see the green energy blink.
If I press this the red LCD is blinking and this is because an interrupt or cared and we just use an
entity blink in here as an example you can put any type of code here you can put an algorithm here that
would be executed if the switch is pressed or if the GPL or pin detect detects a fall in edge.
So that's all there is for this lesson if you have any questions at all.
Just send me a message or leave them in the questions area and I shall see you later.
Have a good day.