1
00:00:04,430 --> 00:00:06,770
So welcome back.

2
00:00:06,770 --> 00:00:15,020
In order to start sending data we have to type out the data function the function that would set the

3
00:00:15,050 --> 00:00:19,100
proper register requirements in place to allow us to send data.

4
00:00:19,550 --> 00:00:21,080
So we would just write to her.

5
00:00:21,080 --> 00:00:22,160
It's very quick.

6
00:00:22,580 --> 00:00:26,080
Let's declare it for LCD data.

7
00:00:26,290 --> 00:00:30,500
Now this boy down here close to the LCD command.

8
00:00:30,590 --> 00:00:31,890
I'll just put it here.

9
00:00:32,030 --> 00:00:36,170
Void LCD on this court data.

10
00:00:36,170 --> 00:00:37,980
And just like the LCD command.

11
00:00:38,030 --> 00:00:45,590
This one takes one argument and this argument is not the type of assigned character we call it data

12
00:00:45,890 --> 00:00:48,980
and this data we want to write to the LCD.

13
00:00:49,760 --> 00:00:58,670
And we said in order to send data to the LCD we have to set the R S pin of the LCD to 1 in order to

14
00:00:58,670 --> 00:01:05,350
allow the internal shift registers of the LCD to choose the data register.

15
00:01:05,880 --> 00:01:07,830
So that's what we do here.

16
00:01:07,940 --> 00:01:16,970
You start by selecting the data register and all we have to do is write which puts a chip a data

17
00:01:20,240 --> 00:01:25,610
and don't let this confuse you GPA or a data and this data has nothing in common.

18
00:01:25,690 --> 00:01:30,370
The states are registered and we want to write to is in the internal.

19
00:01:30,440 --> 00:01:37,370
You know the internals of the LCD the LCD has two registers inside it has one for command and one for

20
00:01:37,370 --> 00:01:43,820
data and we select them and then we write command or select and write data.

21
00:01:43,820 --> 00:01:48,900
And this one here is the basic way of writing to a GPA or pots pin.

22
00:01:49,070 --> 00:01:51,440
We call it GPA or data.

23
00:01:52,220 --> 00:01:55,720
I hope you get the police whatever you do not understand.

24
00:01:55,820 --> 00:01:58,090
It in the comment box below.

25
00:01:58,100 --> 00:01:58,900
Thank you.

26
00:01:58,910 --> 00:02:00,050
So let's continue.

27
00:02:00,050 --> 00:02:06,700
So GPA or a data we write the value 0 x to 0 2.

28
00:02:07,010 --> 00:02:10,690
And basically what this means let me keep you young.

29
00:02:10,790 --> 00:02:20,090
Buying a reform the binary form is this serious you know 1 0 and 1 2 3 4.

30
00:02:20,810 --> 00:02:27,470
Yeah of course this is a 32 bit value or it's supposed to get 32 bit value all of these proceedings

31
00:02:27,470 --> 00:02:33,530
heroes can be cleaned and we can shorten a hair and it would work perfectly.

32
00:02:33,620 --> 00:02:35,240
That's why we keep on right here.

33
00:02:35,240 --> 00:02:39,560
That's why we don't write all the other numbers.

34
00:02:39,850 --> 00:02:40,720
So yeah.

35
00:02:40,730 --> 00:02:53,300
And what this means is our S which is the register select S equals 1 and naval pin Coursera and then

36
00:02:53,420 --> 00:02:59,300
our Coursera show remember our s Let's just check here.

37
00:02:59,390 --> 00:03:03,460
This is p a zero P A one two three.

38
00:03:03,470 --> 00:03:09,850
Keep it for a five when you check your physical connection your red lights that you connected to R S

39
00:03:09,860 --> 00:03:12,020
pinned to a five.

40
00:03:12,020 --> 00:03:20,290
That is why you've changed this p a five to one get called out to set it high to select the data register

41
00:03:20,420 --> 00:03:22,290
inside the LCD.

42
00:03:22,610 --> 00:03:24,120
So yeah.

43
00:03:24,770 --> 00:03:33,020
So once we select a data register we write our data and we do this by a sign in the IQ meant to this

44
00:03:33,440 --> 00:03:36,920
GPA or GPA or a data

45
00:03:40,010 --> 00:03:43,520
equals data.

46
00:03:43,520 --> 00:03:51,200
Basically it's this local variable data that we assign in her and after we do the Senate pass by enabling

47
00:03:51,350 --> 00:04:05,270
P E for a brief moment and what we do is to create a data today and a data then we thought this.

48
00:04:05,270 --> 00:04:06,990
Don't forget to do this.

49
00:04:07,220 --> 00:04:10,110
This vertical line and equal to it.

50
00:04:10,370 --> 00:04:14,670
If you don't put this vertical line and you write directly to it.

51
00:04:14,750 --> 00:04:17,820
Remember they are the same registered to share the same register.

52
00:04:18,170 --> 00:04:23,060
So when we write directly we change in all the values of the register.

53
00:04:23,060 --> 00:04:28,580
If we are to write without this line and then we just write 0 x.

54
00:04:29,450 --> 00:04:36,710
If we are to write just X sorry 0 x 8 0.

55
00:04:37,110 --> 00:04:41,010
If we had to write just this this one is going to happen like always.

56
00:04:41,010 --> 00:04:44,060
Let me break it down to binary for you.

57
00:04:44,760 --> 00:04:50,630
What is going to happen is we are going to have 1 0 0 1 2 3 4.

58
00:04:51,270 --> 00:04:58,270
And as you know a 0 a 1 8 2 8 3 8 4 8 5 6 7.

59
00:04:58,630 --> 00:05:00,250
So this the new value.

60
00:05:00,260 --> 00:05:06,850
But as you can see this fund to us has disabled this set and that we created earlier and we want to

61
00:05:06,850 --> 00:05:08,940
keep this in order to keep this.

62
00:05:09,010 --> 00:05:09,540
We do this.

63
00:05:09,540 --> 00:05:13,570
We use the all operator and we put a vertical line.

64
00:05:13,630 --> 00:05:22,330
So when we put this vertical line this father here this previous setting of the value is added to this

65
00:05:22,330 --> 00:05:25,090
one conclusion

66
00:05:27,990 --> 00:05:31,560
this previous setting is added like this.

67
00:05:31,580 --> 00:05:35,630
And an operation is performed when we perform.

68
00:05:35,630 --> 00:05:45,440
The answer becomes as you can guess it comes 1 0 1.

69
00:05:45,440 --> 00:05:55,280
Remember this one here and to say and then the rest of us to which serious you I've thought is why we

70
00:05:55,300 --> 00:05:56,960
bought this line.

71
00:05:56,980 --> 00:06:04,080
Also if you don't quite get this there is a course on the basics of embedded sea cortex programming

72
00:06:04,150 --> 00:06:06,030
which you can take a quick look at.

73
00:06:06,090 --> 00:06:12,340
It's explains these things in details and it makes programming really easy and robust.

74
00:06:12,340 --> 00:06:16,500
So that being said let's continue.

75
00:06:16,840 --> 00:06:25,810
We have this we've send the pulse and just like we did we delayed Michael delay 0 here which we can

76
00:06:25,810 --> 00:06:35,580
play wait or manipulate this file to her and finally we set it back to ISSUE super cheap or a data register

77
00:06:36,950 --> 00:06:46,400
because 2 x 0 0 and then then we delay again

78
00:06:49,300 --> 00:06:50,090
if we want.

79
00:06:50,110 --> 00:06:54,190
It's always good to be given bits of delay.

80
00:06:54,190 --> 00:07:01,690
Usually the best way is to give the minimum amount of delay as you go on to see how how well the microcontroller

81
00:07:01,690 --> 00:07:08,230
would catch up or how well the LCD will catch up put a microcontroller and then you start reducing the

82
00:07:08,230 --> 00:07:14,830
amount of delay gradually till it still works in order not to slow down the computer so you test you

83
00:07:14,830 --> 00:07:16,990
reduce the amount of delays gradually.

84
00:07:16,990 --> 00:07:22,840
So when we run it and it works we might need to reduce some of this delay amount and when the program

85
00:07:22,840 --> 00:07:25,180
still works which means it's fine.

86
00:07:25,210 --> 00:07:27,810
So now everything is set.

87
00:07:27,910 --> 00:07:35,380
We have to do now as typos are our data.

88
00:07:35,560 --> 00:07:46,760
So the first thing we do we have to clear the screen set the cursor home and remember we call the command

89
00:07:46,790 --> 00:07:49,590
to do this for us.

90
00:07:49,780 --> 00:07:56,650
Let's use this fiscal month as LC to command 2 x 2 1

91
00:07:59,850 --> 00:08:07,590
class to screen LCD command 0 x 0 8.

92
00:08:07,730 --> 00:08:10,400
This sets the coast home now.

93
00:08:10,520 --> 00:08:11,440
This queen is Claire.

94
00:08:11,440 --> 00:08:19,100
The curse I sent home and delay a bit just to allow these commands to finish executing.

95
00:08:21,720 --> 00:08:23,860
Okay good.

96
00:08:23,870 --> 00:08:32,450
How about we compile and see whether the compiler agrees with what we're 3 2 or one warning.

97
00:08:32,450 --> 00:08:34,560
It's probably because of no new line.

98
00:08:34,700 --> 00:08:36,420
It's probably down here.

99
00:08:36,470 --> 00:08:37,290
It should work.

100
00:08:38,780 --> 00:08:40,570
Or two warnings.

101
00:08:40,710 --> 00:08:45,340
Okay so the compiler agrees with what we've written that is great.

102
00:08:45,340 --> 00:08:48,570
So let's just put some basic data here.

103
00:08:48,580 --> 00:08:53,020
Remember data is transferred one character at a time.

104
00:08:53,020 --> 00:08:59,350
Do not worry I know that sounds a bit cumbersome to type one character at a time in the next lesson.

105
00:08:59,350 --> 00:09:06,360
I'll show you a function would engineer a function doubt allow us to type sentences at once.

106
00:09:07,670 --> 00:09:10,270
Let's play with our data and see.

107
00:09:10,480 --> 00:09:12,940
Basically I'm going to call the LC data

108
00:09:18,330 --> 00:09:20,780
how come we cannot see ahead.

109
00:09:20,840 --> 00:09:21,710
Where are you.

110
00:09:21,890 --> 00:09:25,310
Data show.

111
00:09:25,310 --> 00:09:34,800
The reason why LCD data is this way and we couldn't find it into help was because as you can guess we

112
00:09:34,800 --> 00:09:37,710
did not at to prototype up there.

113
00:09:37,930 --> 00:09:48,710
So just like we did for all the our functions as copies is and how to set function code to type now

114
00:09:49,130 --> 00:09:51,730
the only D stuff.

115
00:09:52,100 --> 00:10:01,100
This one here requires an argument I'm going to put on arguments here see like this and the function

116
00:10:01,100 --> 00:10:11,030
works so as great as I'm just going to try C M cortex.

117
00:10:12,380 --> 00:10:22,250
So as we said you can park your data with very very minimal delays to allow the LCD to catch up with

118
00:10:22,250 --> 00:10:24,410
the microcontroller show.

119
00:10:26,070 --> 00:10:32,220
I put a delay here and then I'll call the LCD data again and then write the second correct.

120
00:10:32,250 --> 00:10:33,030
Which is the end

121
00:10:36,770 --> 00:10:38,220
okay.

122
00:10:38,270 --> 00:10:39,040
This should work

123
00:10:42,470 --> 00:10:46,750
delay my could all that to go back to the top of the loop.

124
00:10:47,610 --> 00:10:54,390
Let's see so let's compile this and download onto a board and see what happens.

125
00:10:55,590 --> 00:10:56,220
Okay.

126
00:10:56,280 --> 00:10:58,080
Super errors two warnings

127
00:11:01,660 --> 00:11:04,000
OK it's downloaded.

128
00:11:04,000 --> 00:11:10,900
I hope you've downloaded all your board so please plug in your board download it and then reset your

129
00:11:10,960 --> 00:11:14,700
MCU the microcontroller to see what happens.

130
00:11:17,500 --> 00:11:19,220
So mine is in work.

131
00:11:19,330 --> 00:11:25,540
And I guess yours isn't working as well as a might be wrong given the speed at which we timed out this

132
00:11:25,540 --> 00:11:26,700
long code.

133
00:11:26,740 --> 00:11:30,710
My top mid said all mistyped something.

134
00:11:31,420 --> 00:11:32,600
Let's start from the top.

135
00:11:32,600 --> 00:11:37,330
There are prototypes looks like that in order.

136
00:11:37,480 --> 00:11:38,950
Let's see here.

137
00:11:39,200 --> 00:11:42,600
Okay let's increase this delay effort to millisecond.

138
00:11:43,180 --> 00:11:44,710
Okay.

139
00:11:44,750 --> 00:11:46,690
And then this come here.

140
00:11:46,930 --> 00:11:50,740
I suspect the arrow here goes nothing at all.

141
00:11:50,740 --> 00:11:52,020
Change is on the board.

142
00:11:52,060 --> 00:11:54,130
It has to be the initialization.

143
00:11:54,440 --> 00:11:56,540
Let's see the first one GPI.

144
00:11:56,600 --> 00:11:59,420
Oh this one here.

145
00:11:59,500 --> 00:12:02,390
This one here opens the clock for court.

146
00:12:02,440 --> 00:12:04,220
This one opens the clock for good.

147
00:12:04,520 --> 00:12:05,510
Aha.

148
00:12:05,770 --> 00:12:07,870
There is a problem here.

149
00:12:07,990 --> 00:12:08,460
Okay.

150
00:12:08,470 --> 00:12:13,660
How about we post the video and let's see what you can figure out what the problem is

151
00:12:17,460 --> 00:12:19,690
it's a simple one.

152
00:12:21,020 --> 00:12:24,860
As you can see we dealt with the same issue here.

153
00:12:24,920 --> 00:12:32,120
Remember when we got here and I was explained and I said if we write to this register directly by using

154
00:12:32,120 --> 00:12:35,990
just the equals sign we change in all the values of the register.

155
00:12:36,020 --> 00:12:42,590
So therefore when we get here and we write this new value we wouldn't have our R as selected.

156
00:12:42,590 --> 00:12:44,690
Therefore we have to use this.

157
00:12:44,690 --> 00:12:47,350
It's the same thing happened here.

158
00:12:47,510 --> 00:12:57,680
The RC GC GP registered the this registrar is the same but there are various bits inside to enable different

159
00:12:57,800 --> 00:12:59,200
GP I will pots.

160
00:12:59,240 --> 00:13:02,110
So what we did here was we anybody put a.

161
00:13:02,290 --> 00:13:03,890
And what we got here.

162
00:13:04,010 --> 00:13:12,590
We disabled poor and disabled put the what we want is to enable them both so we can just use the or

163
00:13:12,710 --> 00:13:18,290
operator to add this line here and then would enable it.

164
00:13:18,320 --> 00:13:20,620
So this problem is solved.

165
00:13:20,750 --> 00:13:26,240
Let's see what else we might have lingering around down there.

166
00:13:26,360 --> 00:13:27,090
Let's see.

167
00:13:27,920 --> 00:13:28,880
Aha.

168
00:13:28,980 --> 00:13:30,720
There is another one.

169
00:13:30,980 --> 00:13:32,660
Look at this line.

170
00:13:32,660 --> 00:13:39,620
This line looks okay but it is very problematic actually over here.

171
00:13:39,620 --> 00:13:42,610
What we did was we selected.

172
00:13:44,150 --> 00:13:52,610
We made our eyes course to one using TPA or a course we connected our LCD control registers to the GP

173
00:13:53,150 --> 00:13:56,110
a sort of controlled registers are useful.

174
00:13:56,150 --> 00:13:59,710
Just selection only and the data registers are useful.

175
00:13:59,720 --> 00:14:05,310
Rights and data and data is in the form of command data and actual data.

176
00:14:05,330 --> 00:14:15,710
So when we write 0 x 0 1 which is 2 to enable this screen or to clear the screen this 0 0 1 is a form

177
00:14:15,710 --> 00:14:23,210
of data which is transmitted to the command register and we do it up by telling the LCD we want the

178
00:14:23,210 --> 00:14:27,390
command register active and then we transmit data to where.

179
00:14:27,920 --> 00:14:32,250
But what we did here was we use the.

180
00:14:32,540 --> 00:14:39,200
I should also point out that we use the arm that paints the data pins d you go through a D7 to transmit

181
00:14:39,440 --> 00:14:44,500
in a form of data without the data is actual data or its command data.

182
00:14:44,660 --> 00:14:53,250
We use these pins but we made the mistake of trying to write data to the control the control parts with

183
00:14:53,250 --> 00:14:58,170
it which is GP 8 or a actually it should be GPA.

184
00:14:58,430 --> 00:15:01,350
This is how data is transmitted.

185
00:15:01,520 --> 00:15:07,760
Course we've connected our 8 bits of data line to put to put B.

186
00:15:07,760 --> 00:15:10,040
So let's recap what we just did.

187
00:15:10,610 --> 00:15:11,530
So we came here.

188
00:15:11,570 --> 00:15:20,870
We selected we selected the the LCD data register and we did this by set an R as 2 1 and then we wrote

189
00:15:20,900 --> 00:15:29,300
data we put data into data bus and basically we make GPA will be our data bus and then we put our data

190
00:15:29,330 --> 00:15:35,620
there so I know what might seem confusing as we're using the named data and command.

191
00:15:35,690 --> 00:15:39,340
Meanwhile command actually is a type of data.

192
00:15:39,920 --> 00:15:47,380
So the same thing is affecting this function that we wrote over here we selected our hero.

193
00:15:47,390 --> 00:15:51,080
The only difference between this and this should be are you actually.

194
00:15:51,080 --> 00:15:56,080
So we selected our zero and we have to write a command to it.

195
00:15:56,120 --> 00:16:03,470
And remember this command also has to be put in the database and sent to the command register inside

196
00:16:03,640 --> 00:16:11,510
our Su and we designated codes B I saw one data bus but we forgot we got excited and kept typing and

197
00:16:11,510 --> 00:16:12,490
typing.

198
00:16:12,650 --> 00:16:20,180
So yeah this line here should be GPA would be data and this line should be data anyway.

199
00:16:20,180 --> 00:16:20,820
Yeah.

200
00:16:20,960 --> 00:16:25,100
If anything this error has taught us to pay more attention.

201
00:16:25,310 --> 00:16:32,810
And one last thing I realized right now was we said we have to senate pass through P E while we did

202
00:16:32,810 --> 00:16:32,960
it.

203
00:16:32,960 --> 00:16:38,510
We enabled and didn't disable it mean meaning we did not actually senate pass through it.

204
00:16:38,540 --> 00:16:46,400
We kept it enabled in order to send a oppose would just enable and disable very briefly and we do this

205
00:16:46,400 --> 00:16:54,980
by setting this data register back to 0 x 0 0 and everything should work perfectly.

206
00:16:54,980 --> 00:17:00,020
Now let's compile and let the compiler judge.

207
00:17:00,200 --> 00:17:05,560
Okay so white is working as you can see it's working

208
00:17:08,230 --> 00:17:18,520
and the potential for me to adjust in the contrast is this little one I have heard by turning it contrast

209
00:17:18,580 --> 00:17:19,320
changes.

210
00:17:21,000 --> 00:17:21,700
Yeah.

211
00:17:22,120 --> 00:17:26,440
All we have to do is play with a bulb used in the arm in the data.

212
00:17:26,440 --> 00:17:33,700
Let's try to extend the amount of data we transmit and try to play around with and delay values a bit.

213
00:17:34,270 --> 00:17:37,210
Yeah so see you in the next lesson.
