1
00:00:00,700 --> 00:00:01,130
Hello.

2
00:00:01,230 --> 00:00:02,190
Welcome back.

3
00:00:02,190 --> 00:00:06,010
So in the last lesson we saw how to develop a what.

4
00:00:06,040 --> 00:00:07,260
You drive up.

5
00:00:07,770 --> 00:00:13,470
We created the GPL you as an output and then were able to turn on the LCD.

6
00:00:13,470 --> 00:00:16,810
Now let's see how to make the LCD print blink.

7
00:00:16,890 --> 00:00:25,310
I should say I am going to create a copy of the last project and rename this and then we just continue

8
00:00:25,320 --> 00:00:26,680
from there.

9
00:00:32,110 --> 00:00:32,950
You can open it

10
00:00:40,790 --> 00:00:41,170
right.

11
00:00:41,250 --> 00:00:42,050
It's opened.

12
00:00:42,210 --> 00:00:45,470
So we are going to create a delay function to help us do this.

13
00:00:46,140 --> 00:00:50,520
And I should mention this delay that we want to create is not precise.

14
00:00:50,520 --> 00:00:55,800
Later on when we get to the section on time is we going to see how to create precise delays.

15
00:00:55,800 --> 00:01:02,540
But for now I'm going to create delays I'm going to create our say pseudo delays.

16
00:01:02,540 --> 00:01:05,910
Actually I shouldn't say it's not precise.

17
00:01:05,910 --> 00:01:13,290
This delay is precise but it is calibrated for my my particular configurations and what I mean by this

18
00:01:13,290 --> 00:01:20,340
is it is calibrated for my MCU running at 60 megahertz and using the call you efficient compiler.

19
00:01:20,400 --> 00:01:22,500
So let's see what I mean.

20
00:01:22,530 --> 00:01:25,260
I'm going to create a symbolic name for one second.

21
00:01:25,290 --> 00:01:32,010
I'll call this one sec.

22
00:01:32,040 --> 00:01:38,280
Q You and I'm going to sign this constant so I'm gonna pass this to my register and we're going to keep

23
00:01:38,280 --> 00:01:40,770
minus in one from this taken one from this.

24
00:01:40,800 --> 00:01:47,010
And by the time it reaches zero one second would have passed and then I'm gonna create another symbolic

25
00:01:47,010 --> 00:01:47,420
name.

26
00:01:47,430 --> 00:01:52,920
This is half a second and I'm gonna use this.

27
00:01:52,950 --> 00:01:56,760
I'm gonna use half of this value here which is this.

28
00:01:56,760 --> 00:01:57,220
Right.

29
00:01:57,840 --> 00:02:00,690
So then we can go ahead to create our daily

30
00:02:05,380 --> 00:02:08,020
come down here to create a new subroutine called delay

31
00:02:15,200 --> 00:02:18,050
come here and then I'll see a delay

32
00:02:21,790 --> 00:02:28,460
in this This subroutine shall take the contents of register are three so we are going to part of what

33
00:02:28,460 --> 00:02:29,320
delay amounts.

34
00:02:29,330 --> 00:02:31,670
Our argument is gonna be placed in r 3.

35
00:02:32,360 --> 00:02:34,160
So I'll come here and see sup is

36
00:02:37,010 --> 00:02:44,830
R three are three and then minus one meaning subtract what is an R 3.

37
00:02:45,000 --> 00:02:52,910
So product 1 from the content of our 3 input I resort back into our 3 and then I place the S over here

38
00:02:53,030 --> 00:03:01,400
because I want to update the PSR flags when I perform this operation to subtract operation and the reason

39
00:03:01,400 --> 00:03:07,520
I want to up date the flags is that I want to be able to check what I knew of the flux I set the PSR

40
00:03:07,520 --> 00:03:14,360
flags for those of you who took day the fundamental course the assembly program from ground up we spoke

41
00:03:14,360 --> 00:03:22,370
about those flags we have this zero flag the carry flag the overflow flag so the Zero flag is set when

42
00:03:22,370 --> 00:03:27,510
the previous instruction or the previous operation return the result of zero.

43
00:03:27,830 --> 00:03:30,450
So that flag is gonna be set right.

44
00:03:30,470 --> 00:03:38,360
So I'm gonna say B and E GONNA SEE A B and E delay

45
00:03:41,830 --> 00:03:45,820
and this basically means branch if the Z flag is not equal to zero

46
00:03:48,950 --> 00:03:56,120
meaning if doesn't like you said if the result here if the result here is is zero.

47
00:03:56,150 --> 00:04:03,170
If we keep subtracting from our three if we keep subtracting one from this number and we end at zero

48
00:04:03,470 --> 00:04:05,980
the Z flag is going to be set.

49
00:04:06,500 --> 00:04:12,170
So we check if there is if like you said if it's not set then let's keep subtracting.

50
00:04:12,170 --> 00:04:13,850
If it s not set we keep subtracting.

51
00:04:13,850 --> 00:04:18,710
That is why we seem branch if the C flag is no set meaning we've not arrived at zero yet

52
00:04:34,080 --> 00:04:41,170
and then I'm going to return from the subroutine by doing B X LR like this.

53
00:04:42,160 --> 00:04:42,490
Right.

54
00:04:42,490 --> 00:04:47,950
So I'm going to write a new subroutine known as Lady blink and then I'm going to test all the delay

55
00:04:47,950 --> 00:04:48,650
function to

56
00:04:58,090 --> 00:05:02,020
so we start off by accessing our data register

57
00:05:05,560 --> 00:05:08,860
I'm going to access the data register like we did before

58
00:05:12,800 --> 00:05:24,230
so we have the data register now we've accessed it read We put in our zero and then we turn reality

59
00:05:24,260 --> 00:05:27,820
on this what we do we did this already.

60
00:05:27,830 --> 00:05:37,400
This is our entity on once the LCD on we're going to load one second I'm going to do load R3 with the

61
00:05:37,460 --> 00:05:38,900
constant one second

62
00:05:45,270 --> 00:05:49,140
and once we floated our three we're going to branch two hour delay subroutine

63
00:05:53,220 --> 00:05:58,110
and then we going to turn reality off or just copy this

64
00:06:02,320 --> 00:06:08,010
I'm going to create a symbolic name for 10 in the early days off.

65
00:06:08,650 --> 00:06:11,140
I'm gonna have red off here.

66
00:06:11,140 --> 00:06:15,190
Red is bits number one so red.

67
00:06:15,340 --> 00:06:17,020
So red off I'm gonna do

68
00:06:21,070 --> 00:06:32,080
red off equals shift zero to position one like this I'm gonna take this red off

69
00:06:35,110 --> 00:06:36,170
and put it here.

70
00:06:36,290 --> 00:06:39,990
So we're gonna turn red off and we're gonna delay again.

71
00:06:40,010 --> 00:06:46,940
So start by loading R3 with one second again and then Bill

72
00:06:57,420 --> 00:06:58,670
then we delay.

73
00:06:58,710 --> 00:07:05,850
We go to a delay on subroutine and then this is it.

74
00:07:05,850 --> 00:07:11,180
We can we can keep a branch into the top so that we create a loop here.

75
00:07:13,920 --> 00:07:21,860
Lady blank over here like this so now we can try this out.

76
00:07:21,860 --> 00:07:30,230
I'm gonna copy this label and come over here and because we already have a lady playing us a loop we

77
00:07:30,230 --> 00:07:31,590
can take out this loop.

78
00:07:32,480 --> 00:07:37,280
Okay we can test out our code and see what we have.

79
00:07:37,670 --> 00:07:39,050
I'm going to click here to build

80
00:07:41,880 --> 00:07:44,060
have an arrow here.

81
00:07:44,270 --> 00:07:46,300
It says one sec not defined

82
00:07:51,020 --> 00:07:52,520
okay there's a typo here

83
00:07:57,280 --> 00:07:57,640
okay.

84
00:07:57,820 --> 00:08:00,010
Let's do it again.

85
00:08:00,010 --> 00:08:01,750
It's built successfully.

86
00:08:01,840 --> 00:08:03,050
I'm gonna click it download it.

87
00:08:03,070 --> 00:08:06,630
Mm mm mm mm mm mm mm mm.

88
00:08:06,700 --> 00:08:10,970
I'm gonna download onto my board by clicking here.

89
00:08:11,260 --> 00:08:12,490
It downloaded.

90
00:08:12,530 --> 00:08:17,480
You can see the LCD is blinking at a rate of one second.

91
00:08:17,830 --> 00:08:18,450
Right.

92
00:08:18,460 --> 00:08:19,690
This all the risk for this lesson.

93
00:08:19,690 --> 00:08:22,870
Like I said distillate is not perfectly precise.

94
00:08:22,930 --> 00:08:30,880
This is sort of calibrated as to um you can just take it as a pseudo delay but this is how we are going

95
00:08:30,880 --> 00:08:32,250
to make our lady blink.

96
00:08:32,690 --> 00:08:37,150
Um when we get to the time of section we going to see how to create delays using assisted time is as

97
00:08:37,150 --> 00:08:40,300
well as general papers time is but for now this all the rest.

98
00:08:40,300 --> 00:08:43,160
If you have any questions just let me know and I'll see you later.
