1
00:00:00,810 --> 00:00:01,280
Hello.

2
00:00:01,320 --> 00:00:01,970
Welcome back.

3
00:00:01,980 --> 00:00:07,140
In this lesson we are going to see how to configure our GPI view as an output pin.

4
00:00:08,400 --> 00:00:16,950
I'm gonna make a copy of the last project and then we continue from the core call this GPL you output

5
00:00:17,500 --> 00:00:18,110
input.

6
00:00:18,190 --> 00:00:23,990
Sorry we're going to see how to configure our key player you pin as an input.

7
00:00:24,000 --> 00:00:24,610
Right.

8
00:00:24,630 --> 00:00:25,980
We've already done output

9
00:00:33,580 --> 00:00:34,360
okay.

10
00:00:34,430 --> 00:00:35,420
They were quick to open

11
00:00:40,370 --> 00:00:43,900
to right arm to configure us on input.

12
00:00:43,910 --> 00:00:45,100
It's really simple.

13
00:00:45,110 --> 00:00:52,070
All we have to do is go to the direction register and set it as an input and then we'll have it as an

14
00:00:52,070 --> 00:00:58,680
input but for our experiment we are going to use their switches provided on the port we have switch

15
00:00:58,700 --> 00:01:06,320
one on switch to a P F for and P FS 0 respectively.

16
00:01:06,320 --> 00:01:13,430
We need to enable the um the pull up stuff for these switches so we need to enable the internal pull

17
00:01:13,430 --> 00:01:19,580
up resist the we need to enable the internal pull up resistor that are connected to these two switches

18
00:01:20,120 --> 00:01:28,020
and to enable them we can use the pin up register to enable the internal pull up resistor.

19
00:01:28,190 --> 00:01:34,160
So we have to get uh we have to create the um the address for that.

20
00:01:34,160 --> 00:01:36,200
So I'm going to come over here and create a new address.

21
00:01:36,200 --> 00:01:43,640
I've already gone ahead to get the M to get the offset of the pull up pull up read uh pull up register.

22
00:01:44,420 --> 00:02:00,470
So I'm gonna create it s also GPO F P R for pool upper register offset the offset is 0 x 5 1 0 and you

23
00:02:00,470 --> 00:02:01,990
can go and such.

24
00:02:02,480 --> 00:02:10,080
You are in your data sheet you find this offsets there so to create the um the resistor you simply build

25
00:02:10,080 --> 00:02:25,290
GPL you f p you are on the score are over here and we know we compute this by QPR you f base plus GPL

26
00:02:25,290 --> 00:02:34,090
you p you are offset that is point number 1 1 r right that's another thing we have to deal with.

27
00:02:35,910 --> 00:02:44,670
So our switch PFC row here which is switch number two it is locked by default and this means that we

28
00:02:44,670 --> 00:02:47,690
have to unlock we have to unlock this pin.

29
00:02:47,790 --> 00:02:55,480
The reason this plan is locked is because it is a B PFC row is connected to what is known as the N in

30
00:02:55,480 --> 00:02:57,110
my then non masked ball.

31
00:02:57,150 --> 00:03:03,770
Interrupt and because the the designers of the Texas Instrument microcontroller don't want us to alter

32
00:03:03,780 --> 00:03:11,040
the state of the the the pin by mistake they've locked it such that if we want to use it we've got to

33
00:03:11,130 --> 00:03:16,400
unlock it with a particular unlock key and then we can use it.

34
00:03:16,440 --> 00:03:23,070
So we've got to unlock this and to do it we need to access what is known as the lock register and then

35
00:03:23,070 --> 00:03:30,360
we write a particular unlock to this ones with unlock this we've got a comet what new set in through

36
00:03:30,360 --> 00:03:31,400
the comet right.

37
00:03:31,500 --> 00:03:33,020
Uh comets register.

38
00:03:33,180 --> 00:03:40,800
And mind you we are only doing this because we are using PSU if we connect a own switch to the M to

39
00:03:40,860 --> 00:03:42,290
the microcontroller board.

40
00:03:42,420 --> 00:03:45,730
We don't we don't need to lock in a pin if it's not locked.

41
00:03:45,900 --> 00:03:54,300
Just p f 0 has this issue or for now in our experiment it just has to do a PSU if I'm to connect a pin

42
00:03:54,300 --> 00:04:01,740
to p EF 5 I wouldn't need to unlock it I'll be good to go but because we're using PSU and internally

43
00:04:01,740 --> 00:04:08,160
is connected to the enemy we need to knock it so I'll create the register for lock in on unlocking over

44
00:04:08,160 --> 00:04:21,390
here do you play your f the registers keep a f or call it LC k 4 Look offset the offset here is 0 x

45
00:04:21,420 --> 00:04:22,420
5 2 0

46
00:04:27,510 --> 00:04:39,290
and then we can create the register self keep your f LC K on this call R E Q You would take down the

47
00:04:39,290 --> 00:04:46,610
GPL you f base and then we add this the offset

48
00:04:50,170 --> 00:04:51,010
right.

49
00:04:51,080 --> 00:04:58,440
So this one at I register once we unlock the key we've got to commit the changes and we commit to using

50
00:04:58,460 --> 00:04:59,810
the committee register.

51
00:04:59,810 --> 00:05:03,900
No no C are for short and we can create that as well.

52
00:05:03,950 --> 00:05:14,230
Oh c GPL you f c r offset it can you.

53
00:05:14,700 --> 00:05:30,500
This is or x 5 to 4 and then GPL you f c r underscore R E Q You Cooper you f space address

54
00:05:34,010 --> 00:05:41,690
plus the C are offset.

55
00:05:43,410 --> 00:05:44,280
Right.

56
00:05:44,280 --> 00:05:45,390
So this is it.

57
00:05:45,900 --> 00:05:53,130
So the key the lock key the key to to unlock code port f I'm gonna create a symbolic name to hold this

58
00:05:53,310 --> 00:06:03,740
hexadecimal value and that this can be found in the data sheet as well call this lock key.

59
00:06:05,400 --> 00:06:07,830
This is this value here.

60
00:06:09,800 --> 00:06:10,300
Right.

61
00:06:12,060 --> 00:06:14,590
So I think the set

62
00:06:17,250 --> 00:06:23,550
let's create some symbolic names to correspond to the um the bits of our switch one is switch switch

63
00:06:23,550 --> 00:06:24,010
two.

64
00:06:24,090 --> 00:06:30,480
I'm gonna come over here come down here and say stop you one for switch one

65
00:06:33,360 --> 00:06:44,160
switch one we know is that ping for and then switch two we know this is hard to pin zero

66
00:06:55,520 --> 00:06:55,970
right

67
00:07:02,750 --> 00:07:11,600
um we can create more symbolic names um remember oh uh oh a switch is an octave low switch in and by

68
00:07:11,600 --> 00:07:18,430
default the switch is high when we press the switch it goes slow meaning if we detect that if we wrote

69
00:07:18,440 --> 00:07:26,030
the switch and it state shows that it is low it means someone is pressing it has it is caught on octaves

70
00:07:26,300 --> 00:07:29,870
octave low switch right.

71
00:07:30,350 --> 00:07:34,550
So um I'm going to put a block of comment here

72
00:07:37,400 --> 00:07:38,680
with this output

73
00:07:48,810 --> 00:07:53,140
um let's stop you one pressed

74
00:08:01,340 --> 00:08:03,830
wait let's see how do I write this.

75
00:08:04,610 --> 00:08:07,550
Okay so the output is gonna come out in the um in register.

76
00:08:07,580 --> 00:08:12,880
Iris 0 0 x 0 1.

77
00:08:13,000 --> 00:08:13,690
This will mean

78
00:08:17,830 --> 00:08:18,850
a switch 1

79
00:08:22,620 --> 00:08:24,270
so each one is pressed

80
00:08:27,150 --> 00:08:27,840
sorry bother.

81
00:08:31,680 --> 00:08:32,620
Okay.

82
00:08:32,780 --> 00:08:35,900
If our sorrow which has the output is 0 x

83
00:08:39,290 --> 00:08:41,090
1 0.

84
00:08:41,600 --> 00:08:44,840
This will mean switch to

85
00:08:48,390 --> 00:08:48,930
pressed

86
00:08:52,790 --> 00:08:56,120
if our shoe which is going to be our output register has

87
00:08:58,710 --> 00:09:02,090
0 x 0 0.

88
00:09:02,160 --> 00:09:04,710
This will mean both switches

89
00:09:08,300 --> 00:09:15,960
are pressed if our 0 0 0 x 1 1.

90
00:09:15,960 --> 00:09:16,650
This will mean

91
00:09:20,820 --> 00:09:23,070
no switch is pressed.

92
00:09:23,070 --> 00:09:24,780
Remember we said it's active low

93
00:09:27,450 --> 00:09:28,670
right.

94
00:09:28,710 --> 00:09:36,210
So this is a comment so I'm going to highlight this and comments for your explanation.

95
00:09:36,210 --> 00:09:41,630
Okay I'm gonna create symbolic names to hold these state.

96
00:09:42,510 --> 00:09:56,370
So come over here I'll s top you one on the score prized and there's a Q You 0 x 0 1 and then I stop

97
00:09:56,380 --> 00:10:05,480
you too on a score pressed this AQ you score x 1 0.

98
00:10:05,680 --> 00:10:14,600
This both pressed AQ you sure x.

99
00:10:14,620 --> 00:10:18,760
Sure sure this no press

100
00:10:21,650 --> 00:10:26,830
AQ you sure x 1 1 right.

101
00:10:26,840 --> 00:10:31,130
So now we have all the registers and symbolic names we need.

102
00:10:31,720 --> 00:10:32,540
Yeah.

103
00:10:33,010 --> 00:10:38,080
So how about we continue in the next lesson this implement our code in the next lesson.

104
00:10:38,080 --> 00:10:38,640
I'll see you there.
