1
00:00:02,210 --> 00:00:02,740
Hello.

2
00:00:02,810 --> 00:00:03,370
Welcome back.

3
00:00:03,450 --> 00:00:09,410
So we still need general purpose input output section and in this lesson we're going to demonstrate

4
00:00:09,410 --> 00:00:15,880
how to create an external input interrupt function using the and 132 cubit next.

5
00:00:15,980 --> 00:00:16,930
Well we want to do it.

6
00:00:16,940 --> 00:00:24,290
We want to see the interrupt lines connected to the various GPO pins and we can find that from the reference

7
00:00:24,740 --> 00:00:28,770
the reference module of the estimate that the microcontroller.

8
00:00:28,770 --> 00:00:33,940
And this time we don't need to go to Google to look for a cause call your vision has assembled the books

9
00:00:33,940 --> 00:00:34,380
here.

10
00:00:34,750 --> 00:00:37,640
I could just come over here and go to the reference module.

11
00:00:37,640 --> 00:00:46,070
This particular book double click to open and once it opens I can search extend or interrupt again it

12
00:00:46,070 --> 00:00:50,640
is extend or interrupt slash defense control of this what we're looking for.

13
00:00:50,750 --> 00:00:53,650
It's on this page here one hundred and ninety eight.

14
00:00:53,680 --> 00:00:54,900
Or just click it.

15
00:00:55,100 --> 00:00:56,750
And then what I want is down here.

16
00:00:56,750 --> 00:01:01,440
I just want to see which interrupts line my push button is connected to.

17
00:01:01,520 --> 00:01:06,910
So as we can see P A zero is connected to extend interrupts line zero.

18
00:01:07,190 --> 00:01:13,880
And if we want to use a different pin for extend or interrupt we have the option is to use to zero pieces

19
00:01:13,880 --> 00:01:16,820
you APD you use your X etc..

20
00:01:16,880 --> 00:01:19,660
So what we need to program is to extend all interrupt lines here.

21
00:01:20,150 --> 00:01:20,800
That's good.

22
00:01:20,810 --> 00:01:23,750
And we already know where our LCD is connected.

23
00:01:23,750 --> 00:01:28,990
So we have all we need to go to Cuba makes to create a new projects to demonstrate this.

24
00:01:29,000 --> 00:01:30,510
So let's head to Cuba next.

25
00:01:30,510 --> 00:01:32,260
Now this is our own project.

26
00:01:32,270 --> 00:01:41,080
And what I'm going to do is I'm just going to create a new project or just minimize all of this this

27
00:01:41,090 --> 00:01:42,570
creates a new project from here.

28
00:01:42,590 --> 00:01:48,760
You project and I'm still using the same boat as the estimate.

29
00:01:48,760 --> 00:01:59,170
That's a two disco board by microcontrollers to the same double click this office cleaned up paints

30
00:01:59,170 --> 00:02:01,960
by just going to clamping out.

31
00:02:01,960 --> 00:02:03,290
Yes.

32
00:02:03,310 --> 00:02:10,370
And this time I want to activate PD to us extend or interrupt like this.

33
00:02:10,510 --> 00:02:13,280
And then we still use our PD 13.

34
00:02:13,420 --> 00:02:20,140
So keep your output to two lights up our entity and let's get another entity for this project.

35
00:02:20,720 --> 00:02:22,810
I'll just use this one here.

36
00:02:22,900 --> 00:02:23,810
I don't know which color.

37
00:02:23,830 --> 00:02:29,580
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.

38
00:02:29,630 --> 00:02:31,100
Remember them later.

39
00:02:31,450 --> 00:02:33,550
And yes this is all there is to it.

40
00:02:33,710 --> 00:02:39,900
And we have to settle on debugger or just select the zero Y overhead and it's initialized for me.

41
00:02:40,150 --> 00:02:47,260
Next I can I can leave the configuration to the default settings and over here.

42
00:02:47,330 --> 00:02:53,840
Now we have to configure to interrupt what we want to do is click the ethic and select the interrupt

43
00:02:53,860 --> 00:02:56,280
we use in the external interrupts lines here.

44
00:02:56,300 --> 00:02:59,920
So we just have to take this one here and that's all there is to it.

45
00:02:59,930 --> 00:03:06,620
And then I click OK next i click over here to generate my code and I give my project a name call it

46
00:03:06,620 --> 00:03:19,640
extend or interrupt external on the school interrupt and I'm using the call and decoded version 5 and

47
00:03:19,870 --> 00:03:22,340
I leave everything else the same I click OK

48
00:03:25,360 --> 00:03:29,970
it generates it then once it's done I click open project

49
00:03:33,820 --> 00:03:37,480
and once this is done I can just expand this and take a look at this.

50
00:03:38,150 --> 00:03:41,930
And to bind everything together I'll just rebuild the project

51
00:03:47,390 --> 00:03:53,960
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

52
00:03:53,960 --> 00:03:55,170
infinite loop here.

53
00:03:55,190 --> 00:03:59,090
I can come over here and see Hall GPI.

54
00:03:59,090 --> 00:03:59,860
All right.

55
00:04:05,200 --> 00:04:09,270
And I could just give the ports no cheaper imports D.

56
00:04:10,700 --> 00:04:14,780
And GPI you 10 13

57
00:04:19,910 --> 00:04:22,210
and I could just write it to one.

58
00:04:23,060 --> 00:04:28,120
We initialize them just go and verify this quickly pan out.

59
00:04:28,780 --> 00:04:30,470
So we have 12 and 13.

60
00:04:30,470 --> 00:04:38,270
So let's just keep the entity connected to pin twelve on all the time and let's still control the orange

61
00:04:38,360 --> 00:04:40,600
energy use in our push button.

62
00:04:40,670 --> 00:04:47,480
So when I compile this we are just going to see that one end to be on this reboot and in fact you can

63
00:04:47,480 --> 00:04:50,510
verify which entity it is from the user guide.

64
00:04:50,830 --> 00:04:56,880
And once that is done building it can reset and I can see that green entity is on.

65
00:04:56,900 --> 00:05:06,110
So we want to keep the green energy on at all times and we can have our of our button 10 on the the

66
00:05:06,110 --> 00:05:08,780
orange LRT and we can do this in the interrupt.

67
00:05:08,780 --> 00:05:11,840
So what we want is to use interrupts to do this.

68
00:05:11,840 --> 00:05:16,440
So we have to populate the interrupt callback function to do that.

69
00:05:16,500 --> 00:05:21,530
Let's just assume I don't remember the nature of the function cyclic functions that come overhead.

70
00:05:21,530 --> 00:05:28,700
I select this particular module the GPI and then I expanded and it should tell me over here how it you

71
00:05:28,700 --> 00:05:35,150
tell you extend an interrupt and it should give me the external interrupt.

72
00:05:35,510 --> 00:05:42,550
So this what I need to extend or interrupt callback so I can I have to edit this function by put in

73
00:05:43,180 --> 00:05:49,920
the code I want to execute when to interrupt OK is inside this function without using this key word

74
00:05:50,010 --> 00:05:51,360
weak key word here.

75
00:05:51,560 --> 00:05:55,270
This week key word means you can redefine the function.

76
00:05:55,430 --> 00:05:56,560
You can customize it.

77
00:05:57,200 --> 00:06:02,150
And the next time the compiler is looking for that particular function you would use the function you

78
00:06:02,150 --> 00:06:06,080
have defined without the weak keyword.

79
00:06:06,080 --> 00:06:09,990
So what I want is I just want to paste up function here and clean this here.

80
00:06:10,730 --> 00:06:16,490
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

81
00:06:16,490 --> 00:06:21,850
as soon as the pen is pressed the interrupt to interrupt to detect the presence of the pin.

82
00:06:21,860 --> 00:06:29,120
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

83
00:06:29,120 --> 00:06:43,740
with interrupt already rights being GPL Hootie API you pin 13 and that's all there is to it.

84
00:06:44,090 --> 00:06:56,300
And I just write to high class argument so I can build head and I'll just enable the reset and run option

85
00:06:57,980 --> 00:06:59,390
by ticking like this.

86
00:06:59,500 --> 00:07:00,110
Okay.

87
00:07:00,140 --> 00:07:00,470
And then.

88
00:07:00,470 --> 00:07:06,890
Okay then I'll download onto my boat and it's finished downloading.

89
00:07:06,930 --> 00:07:14,590
And as you can see it credibility entity is on when I press this the instructive case the audience goes

90
00:07:14,590 --> 00:07:18,220
on and I didn't put in a code to turn it back off.

91
00:07:18,220 --> 00:07:20,420
So this is what we expect.

92
00:07:20,470 --> 00:07:25,390
You can toggle here or you can do it in a form of computation here in.
