1
00:00:00,660 --> 00:00:01,030
Hello.

2
00:00:01,050 --> 00:00:01,820
Welcome back.

3
00:00:01,830 --> 00:00:07,030
In this lesson we should take a look at another digital input output example.

4
00:00:07,050 --> 00:00:11,570
This lesson also teach us how to unlock sets in locked panes.

5
00:00:11,610 --> 00:00:17,490
So some of the pins on a wire microcontroller because they are used for other functions by default they

6
00:00:17,490 --> 00:00:19,500
are locked in order to use them.

7
00:00:19,500 --> 00:00:21,390
We need to unlock them.

8
00:00:21,390 --> 00:00:26,970
This lesson is going to show us how to perform such on lock in so I'm going to create a new project

9
00:00:26,970 --> 00:00:29,040
over here.

10
00:00:29,130 --> 00:00:34,680
Create this new vision project or save Main.

11
00:00:35,050 --> 00:00:36,210
We have projects.

12
00:00:36,240 --> 00:00:37,540
Come over here.

13
00:00:37,540 --> 00:00:40,200
Great new photo for it.

14
00:00:40,200 --> 00:00:44,660
I call this GPI you unlock it

15
00:00:47,770 --> 00:00:58,480
and then we didn't fold our creative forward GPO a unlock in and then team 4C.

16
00:00:58,570 --> 00:00:59,410
One two three.

17
00:00:59,440 --> 00:01:02,520
U h 6 p.m..

18
00:01:03,500 --> 00:01:05,050
Select the board.

19
00:01:05,140 --> 00:01:05,580
Okay.

20
00:01:05,630 --> 00:01:06,870
Over here.

21
00:01:07,030 --> 00:01:12,210
She says isolate the core device isolate the startup over here like this.

22
00:01:12,590 --> 00:01:13,680
Okay.

23
00:01:13,850 --> 00:01:16,250
And Target over here.

24
00:01:16,250 --> 00:01:23,240
I'm going to see a Tim 4C One two three and I'm going to expand their source group or select Oh.

25
00:01:23,270 --> 00:01:32,400
Change the name to AP and GONNA COME TO TARGET OPTIONS set the X all to 16 over here and debug outcrop

26
00:01:32,450 --> 00:01:40,030
down in select SD link select still areas I CDI yeah And over here I'll take this.

27
00:01:40,070 --> 00:01:40,450
And then.

28
00:01:40,490 --> 00:01:41,080
Okay.

29
00:01:41,090 --> 00:01:41,430
And then.

30
00:01:41,450 --> 00:01:45,610
Okay come over here right click each new item.

31
00:01:45,620 --> 00:01:47,550
See and then I'll give it a name.

32
00:01:47,600 --> 00:01:49,210
Main here like this.

33
00:01:49,310 --> 00:01:50,790
Right.

34
00:01:50,840 --> 00:01:52,470
And I'm going to bring our pin out.

35
00:01:53,430 --> 00:02:00,370
Going copy and paste our pin up here so that we know which pins we are dealing with right to proceed

36
00:02:00,370 --> 00:02:06,730
by including my microcontroller header followed by right clicking include this over here like this.

37
00:02:06,730 --> 00:02:11,790
So in this example we're going to use the switch too which is connected to PFC row and we'll use this

38
00:02:11,790 --> 00:02:14,410
switch too because p of zero is locked.

39
00:02:14,410 --> 00:02:18,190
By default it's connected to something known as the enemy.

40
00:02:18,520 --> 00:02:21,220
And because of this by default it is locked.

41
00:02:21,220 --> 00:02:26,650
If we want to configure it we've got to tell the microcontroller we've got to sort of take extra steps

42
00:02:26,740 --> 00:02:33,940
in order to use PFO 0 right and unjust and enabling the pin to because of that would practice with P.F.

43
00:02:33,940 --> 00:02:35,090
0 in this course.

44
00:02:35,110 --> 00:02:35,950
In this lesson.

45
00:02:36,230 --> 00:02:37,740
So come over here.

46
00:02:37,780 --> 00:02:40,660
Create the main enemy over here

47
00:02:45,100 --> 00:02:57,010
and open and close and we're going to initialize clock access to port F so RC GC GPA will register pass

48
00:02:57,010 --> 00:02:57,730
you X

49
00:03:00,730 --> 00:03:02,770
to zero over here like this.

50
00:03:02,890 --> 00:03:11,980
Once that is done so to unlock the pin we've got to access the Dethklok register as a block register

51
00:03:12,020 --> 00:03:17,970
we've got to access the clock register and write a particular proc code to it to there's a particular

52
00:03:18,620 --> 00:03:24,440
32 bit value we need to write this register in order for you to unlock and the value we need to write

53
00:03:24,530 --> 00:03:33,890
this time is this one here we need to write 0 x for C for F for 3 and 4 b in order to unlock PSU.

54
00:03:34,450 --> 00:03:43,070
So I'm going to come over here and I'm going to access GPI or port F and then the lock register and

55
00:03:43,070 --> 00:03:46,340
then I'm going to write this file due to the lock register

56
00:03:48,680 --> 00:03:50,450
core this

57
00:03:54,050 --> 00:03:55,640
unlock value like this

58
00:03:58,350 --> 00:03:59,470
right.

59
00:03:59,480 --> 00:04:06,590
I'm going to write this so once we've written this value to the unlock once we've written this to the

60
00:04:06,590 --> 00:04:14,000
lock register we have to take another step we have to access to see our register and enable the um the

61
00:04:14,000 --> 00:04:20,490
bids for PSU before we can configure it so to do that I'm going to come over here and see GPI.

62
00:04:20,600 --> 00:04:21,080
F

63
00:04:25,490 --> 00:04:32,750
and then see R and then I'm going to set the pin 0 the bits corresponding to 0 high and I'm going to

64
00:04:32,750 --> 00:04:41,300
do that by simply writing your ex 0 1 and you know if I expand this this corresponds to bit zero off

65
00:04:41,300 --> 00:04:45,000
the of this nimble being set high.

66
00:04:45,140 --> 00:04:47,150
Once that is done I'll put some committee actually

67
00:05:00,070 --> 00:05:01,580
and over here we've seen

68
00:05:04,770 --> 00:05:13,830
on lock commits register so this the commits register we first need to unlock the comet's register before

69
00:05:13,880 --> 00:05:19,050
we're able to tell the comet's registered to make PFC real configurable.

70
00:05:19,050 --> 00:05:24,860
Once that is done we can proceed with a normal sequence by accessing the direction register.

71
00:05:24,880 --> 00:05:27,800
I'll say keep you f over here.

72
00:05:27,930 --> 00:05:28,770
Ah.

73
00:05:29,100 --> 00:05:36,900
And then I'll say 0 x says you X over here and your x 0 8.

74
00:05:37,050 --> 00:05:44,250
We still work in your X A2 actually because we're dealing with the green entity which is this one here

75
00:05:45,200 --> 00:05:50,340
P F three the green and the DP F 3 0 8 like this.

76
00:05:50,340 --> 00:05:50,750
Right.

77
00:05:50,840 --> 00:05:59,840
And we can expand this to C we set in 0 8 as outputs so as your aids gives us binary one two three four

78
00:05:59,910 --> 00:06:02,750
and one one two three.

79
00:06:02,760 --> 00:06:03,210
Right.

80
00:06:03,480 --> 00:06:08,420
So this corresponds to P.F. 3 we set an output once that is done.

81
00:06:08,520 --> 00:06:18,510
We accessed the enable registered GPI or f the end and we set both our switch and both our switch and

82
00:06:18,520 --> 00:06:23,060
our P F three which is the elder pin as these two pins.

83
00:06:23,190 --> 00:06:27,870
So they switch is connected to peer four over here.

84
00:06:27,980 --> 00:06:32,910
Four bit four so bit voice zero one two three four.

85
00:06:33,210 --> 00:06:40,830
So by here to get here for we simply do 0 x 1 0 and this one here corresponds to 4.

86
00:06:41,220 --> 00:06:43,570
So we change this to 8 over here.

87
00:06:43,650 --> 00:06:47,160
So we're dealing with PFC you over here right.

88
00:06:47,190 --> 00:06:50,870
So we want to set SPF 0 1 to enable PSU.

89
00:06:50,880 --> 00:06:58,770
So we simply need to change this bit here to 1 2 what we have to do in hexadecimal is we've got to do

90
00:06:58,770 --> 00:07:03,660
0 0 0 4 zeros and then 1 0 0 1.

91
00:07:03,840 --> 00:07:04,410
Right.

92
00:07:04,440 --> 00:07:09,350
So we've got to have this in hexadecimal form so we can simply pass the number nine here.

93
00:07:09,360 --> 00:07:19,020
This corresponds to 0 x 0 9 so x 0 9 here would set both our sets.

94
00:07:19,020 --> 00:07:25,650
Both our PSU and P F three US digital teams.

95
00:07:25,830 --> 00:07:28,200
That's what we're doing here.

96
00:07:28,200 --> 00:07:29,320
I'll put a comment here.

97
00:07:43,340 --> 00:07:44,170
Right.

98
00:07:44,420 --> 00:07:53,150
We've got to enable the pull up register come over here and see GPA you f and then P U R pull up is

99
00:07:53,150 --> 00:07:58,900
connected to our bits 0 of port F so I say is your x.

100
00:07:58,900 --> 00:08:03,240
Sure wonder why here to enable it.

101
00:08:04,320 --> 00:08:13,190
And once that is done we can come over here and do what we did before we can say while 1 and we have

102
00:08:13,190 --> 00:08:23,420
to read the State of the GPL FDA to register and perform a bit twice and with which pin 0 and c to come

103
00:08:23,420 --> 00:08:35,240
over here and see if GPL u f data register and 0 x 0 1.

104
00:08:35,750 --> 00:08:40,660
If this is false because this is also an active Lupin.

105
00:08:40,850 --> 00:08:45,440
If this is false it means that the button has been pressed right.

106
00:08:45,440 --> 00:08:47,900
If this forced then what we want to do is

107
00:08:50,710 --> 00:09:00,020
turn on our ability and we do that by seeing GP I o f the LSD is connected to P F 3 which is your x

108
00:09:00,050 --> 00:09:05,430
8 a data register true 2 x 8.

109
00:09:05,610 --> 00:09:07,320
Want to set this high.

110
00:09:07,340 --> 00:09:12,770
If this not if this is not a case we can point out before getting it brackets here actually

111
00:09:15,350 --> 00:09:20,100
if this is not a case we can put an LS condition here.

112
00:09:20,270 --> 00:09:25,780
Else we open close and in here we see a GP.

113
00:09:25,850 --> 00:09:26,300
F

114
00:09:29,370 --> 00:09:38,850
data and then we use the amber sunshine and to add a sign here to just disable this bit like this.

115
00:09:40,320 --> 00:09:44,120
So once this is done we can build and see what it looks like.

116
00:09:44,130 --> 00:09:46,940
Click over here to build.

117
00:09:47,130 --> 00:09:49,280
Now let's download onto our board.

118
00:09:49,570 --> 00:09:53,700
Quint Click here to download onto the board and it's downloaded.

119
00:09:53,730 --> 00:09:54,920
Now let's see what we have.

120
00:09:54,930 --> 00:09:58,020
Click over here and I say press the switch.

121
00:09:58,020 --> 00:10:01,320
No one would say press I say.

122
00:10:01,680 --> 00:10:06,590
And I say and I say press switch to here which is connected to PFC row.

123
00:10:06,810 --> 00:10:08,660
We can see the LCD on.

124
00:10:08,960 --> 00:10:13,690
You can see the LCD tan on how about we comment out a code.

125
00:10:13,740 --> 00:10:17,490
These new lines we added the unlock lines.

126
00:10:17,490 --> 00:10:21,960
Let's see what happens if we fail to unlock the PFC row.

127
00:10:22,500 --> 00:10:26,400
So I reveal this and I don't go down to the board.

128
00:10:26,400 --> 00:10:33,640
So these green LCD is on because P FS you over here PFC over here and it's locked.

129
00:10:33,660 --> 00:10:34,400
St..

130
00:10:34,490 --> 00:10:37,360
Reed zero when we read PFC row.

131
00:10:37,440 --> 00:10:38,420
It's locked.

132
00:10:38,490 --> 00:10:40,720
We get a values you.

133
00:10:40,770 --> 00:10:48,710
Once we unlock it then it is associated to the switch the S.W. W2 here and DSW too is an octave low

134
00:10:48,720 --> 00:10:49,500
as W2.

135
00:10:49,740 --> 00:10:55,400
So once we unlock it it states becomes high with without we pressing it.

136
00:10:55,440 --> 00:11:00,820
When we press it it goes slow but when it's locked it is zero.

137
00:11:00,900 --> 00:11:07,830
Once it's unlocked it becomes an active low switch and by active low it means its default state is high.

138
00:11:07,860 --> 00:11:08,500
When we press.

139
00:11:08,520 --> 00:11:12,830
And then of course load to going to comments this.

140
00:11:12,850 --> 00:11:21,190
So now we unlock the pin click over here to build click here to download onto the board and I can see

141
00:11:21,280 --> 00:11:27,640
it's unlocked now and the ladies off because it's octave low because this condition is was met.

142
00:11:27,640 --> 00:11:28,530
Now.

143
00:11:28,570 --> 00:11:28,860
Right.

144
00:11:28,870 --> 00:11:33,200
I'm going to press it and I can see it comes on I say.

145
00:11:33,200 --> 00:11:35,350
Press So this order is for this lesson.

146
00:11:35,350 --> 00:11:39,700
If you have any questions at all just let me know and I shall see you in the next lesson.

147
00:11:39,700 --> 00:11:40,390
Have a good day.
