1
00:00:00,680 --> 00:00:01,080
Hello.

2
00:00:01,100 --> 00:00:01,970
Welcome back.

3
00:00:01,970 --> 00:00:06,980
So in the previous lesson we saw how to configure and detect GPI.

4
00:00:06,980 --> 00:00:16,310
You interrupt and we used GPI report F and we were able to execute what was in the GPI you put f interrupt

5
00:00:16,310 --> 00:00:20,360
handler whenever it switch one or switch to is pressed.

6
00:00:20,510 --> 00:00:26,630
But I suppose that left you wondering how do we differentiate switch one from switch two since we were

7
00:00:26,630 --> 00:00:29,010
using the same interrupt handler for that.

8
00:00:29,180 --> 00:00:36,110
What if we want a different set of instructions to execute when it's a switch one and then another different

9
00:00:36,110 --> 00:00:43,610
set for switch to how do we do that given that both of them are connected to port F and we've got just

10
00:00:43,610 --> 00:00:50,990
one port f interrupt request handler so we're going to show that in this lesson I'm going to create

11
00:00:50,990 --> 00:00:58,910
a copy of the last project and I'll paste this copy here and then rename it to version 2 and then we

12
00:00:58,910 --> 00:01:00,020
continue from there.

13
00:01:02,480 --> 00:01:11,630
Port underscore fee 2 Over here then I'm going to open this and I'm going to close this project then

14
00:01:11,630 --> 00:01:14,530
I'm going to open fee 2 and then I'll open from here

15
00:01:18,670 --> 00:01:19,060
right.

16
00:01:19,150 --> 00:01:26,770
So this our previous projects and we've got GPL you put F over here aren't we totally into green LCD.

17
00:01:26,860 --> 00:01:34,330
Three times when the GPL you put a forecast in this case when we press any of these switches we have

18
00:01:34,370 --> 00:01:36,580
on our team that to our seaboard.

19
00:01:36,610 --> 00:01:42,550
Now what we're going to do is we're going to let one switch target with a red LCD and another one is

20
00:01:42,650 --> 00:01:44,070
toggle the green one.

21
00:01:44,080 --> 00:01:48,370
So currently we are totally in the red already in the infinite while one loop.

22
00:01:48,430 --> 00:01:53,260
I'm going to delete that so that there'll be nothing happening in a while one loop is just going to

23
00:01:53,260 --> 00:01:53,830
be empty

24
00:01:56,650 --> 00:02:06,600
like this and to detect which interrupt or cared we're going to use an if and check the Empire's register

25
00:02:06,600 --> 00:02:11,910
to see whether the interrupt is from pin for or pin 0.

26
00:02:12,120 --> 00:02:14,040
So let's do that now.

27
00:02:14,250 --> 00:02:17,190
I'm going to come up here.

28
00:02:17,470 --> 00:02:21,540
I'm going to just bring it here because we need what is up here.

29
00:02:21,540 --> 00:02:31,050
So we're going to start by saying well GPL you f minus

30
00:02:34,360 --> 00:02:37,410
is not equal to zero.

31
00:02:37,870 --> 00:02:41,870
Then we open this block and then we'll check if it is.

32
00:02:41,870 --> 00:02:47,820
Which one by saying if you call your f am I s

33
00:03:01,630 --> 00:03:05,020
and you're X once you're

34
00:03:24,120 --> 00:03:27,120
if this is the case then we're going to target with the.

35
00:03:27,870 --> 00:03:34,300
I'm just going to fudge this code over here to target the green entity gonna fetch all of this actually

36
00:03:36,100 --> 00:03:38,230
all of this screen to be fetched

37
00:03:43,290 --> 00:03:53,180
and pasted in here so if this is the case wanted to go the green LCD three times right.

38
00:03:53,260 --> 00:03:55,140
So we have to come out here and do.

39
00:03:55,140 --> 00:03:55,930
Else if

40
00:04:01,080 --> 00:04:12,540
you play your f m s and sure of X through one and this chick this is chick

41
00:04:18,560 --> 00:04:27,590
chick if esta Picchu which is PFC PSU if that's the case I'm going to paste this I'm going to change

42
00:04:27,590 --> 00:04:38,570
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.

43
00:04:38,570 --> 00:04:41,030
Often the interrupt should should should.

44
00:04:41,030 --> 00:04:44,870
CLAIRE Well with Claire it and when we read back.

45
00:04:44,960 --> 00:04:51,920
But if all of this doesn't make sure the interrupt is Claire we've got to force it to Claire and to

46
00:04:51,920 --> 00:04:52,310
do that.

47
00:04:52,340 --> 00:04:56,200
I'm gonna come over here and say.

48
00:04:56,220 --> 00:05:12,080
Else open a block here and see GPI you f I see are you cause you f m my ass.

49
00:05:12,350 --> 00:05:18,680
And we do read back because you play F I see ya.

50
00:05:19,810 --> 00:05:20,260
Right.

51
00:05:21,040 --> 00:05:27,400
So now we should be able to execute we should be able to execute based on the.

52
00:05:27,450 --> 00:05:36,870
We should be able to execute different instructions based on the um the pin so this block here

53
00:05:40,530 --> 00:05:50,070
is for switch one and this other block here for switch to CODIS PSU ISO

54
00:05:54,420 --> 00:05:56,310
PFC or ISIS touch here

55
00:06:03,420 --> 00:06:04,280
right.

56
00:06:04,320 --> 00:06:07,310
So like I said we're just using the utilities as examples here.

57
00:06:10,310 --> 00:06:11,500
Right.

58
00:06:11,600 --> 00:06:14,720
So let's build and see how it looks.

59
00:06:14,930 --> 00:06:20,430
Click here to build let's get it on our board.

60
00:06:20,430 --> 00:06:20,850
Right.

61
00:06:20,850 --> 00:06:25,680
So before we download onto our board we first need to enable global interrupt.

62
00:06:25,680 --> 00:06:30,840
Over here we disabled interrupt globally and we've got to enable interrupt back in order to be able

63
00:06:30,840 --> 00:06:31,630
to interrupt.

64
00:06:32,110 --> 00:06:35,540
So C enable our over here.

65
00:06:35,540 --> 00:06:38,700
And once that is done are revealed by clicking over here

66
00:06:42,100 --> 00:06:48,110
and click here to download onto the board.

67
00:06:48,550 --> 00:06:50,980
And once that's done we can see.

68
00:06:51,020 --> 00:06:52,620
So this our board.

69
00:06:52,610 --> 00:06:55,440
Now there is no LCD blinking at all.

70
00:06:55,530 --> 00:07:02,990
And we said we should blink the LCD when once we should blink the LCD based on the interrupt that occurs

71
00:07:03,020 --> 00:07:07,220
and with attached interrupt to our switch zero and switch one.

72
00:07:07,280 --> 00:07:10,630
So if I press the switch you can see the green energy blink.

73
00:07:10,700 --> 00:07:17,210
If I press this the red LCD is blinking and this is because an interrupt or cared and we just use an

74
00:07:17,300 --> 00:07:23,840
entity blink in here as an example you can put any type of code here you can put an algorithm here that

75
00:07:23,840 --> 00:07:31,830
would be executed if the switch is pressed or if the GPL or pin detect detects a fall in edge.

76
00:07:32,480 --> 00:07:35,030
So that's all there is for this lesson if you have any questions at all.

77
00:07:35,030 --> 00:07:38,930
Just send me a message or leave them in the questions area and I shall see you later.

78
00:07:38,930 --> 00:07:39,670
Have a good day.
