1
00:00:04,180 --> 00:00:07,990
So now let's start to write out our code.

2
00:00:08,020 --> 00:00:09,820
I'm going to delete this line here.

3
00:00:09,820 --> 00:00:10,690
It's not needed.

4
00:00:10,690 --> 00:00:12,720
It was for your reference only.

5
00:00:12,970 --> 00:00:14,680
And we're going to stop by right now.

6
00:00:14,680 --> 00:00:20,300
Our directives remember the directives they help the Compiler Compiler the code in a particular way.

7
00:00:20,410 --> 00:00:22,740
We're going to start by hitting four tops.

8
00:00:22,750 --> 00:00:24,300
One two three four.

9
00:00:24,400 --> 00:00:34,660
And I will start with a first directive shall be written in Cobb's area and then tab vertical line dot.

10
00:00:34,820 --> 00:00:42,850
And this directive here makes our code callable from a C code a code written in C and we add the other

11
00:00:42,850 --> 00:00:51,640
directive C or D is tells the compiler to place the following line in the code space which is usually

12
00:00:51,640 --> 00:00:53,500
the wrong comma.

13
00:00:53,770 --> 00:01:03,700
Let's just make it read only safe this way unless our line line it of to.

14
00:01:04,220 --> 00:01:13,810
Now we could tell the compiler that our code is written in thumb to empty thumb.

15
00:01:15,330 --> 00:01:22,060
And then we export our program and export our program

16
00:01:26,260 --> 00:01:29,830
and we're going to call Let's call our program made.

17
00:01:30,040 --> 00:01:36,160
So we export main you know what the export directive does.

18
00:01:36,160 --> 00:01:42,400
It makes this program of this program callable from other other programs.

19
00:01:42,430 --> 00:01:46,480
So this file the content of this file can be caught from other files.

20
00:01:46,630 --> 00:01:53,980
You know the dot text makes it callable to see files by export makes it callable to assembly files and

21
00:01:53,980 --> 00:01:58,730
see files and it takes would not work without the export main.

22
00:01:58,750 --> 00:02:00,230
So now our program is made.

23
00:02:00,250 --> 00:02:01,810
So we export in Maine.

24
00:02:02,770 --> 00:02:06,240
So now let's write out our program.

25
00:02:06,730 --> 00:02:15,250
We start by in Maine the first and we're going to do is initialize our pot and pen and we're going to

26
00:02:15,280 --> 00:02:18,420
do this by writing a subroutine to do that for us.

27
00:02:18,430 --> 00:02:25,770
And remember there to be L is branch 2 subroutine I'm going to use the P L up code to do this and we're

28
00:02:25,770 --> 00:02:35,110
going to call this first subroutine G P i o f in it as the name implies it's going to initialize the

29
00:02:35,560 --> 00:02:40,340
general purpose input output to put s KPI in it.

30
00:02:40,360 --> 00:02:46,270
And remember we want to turn on the red LCD and we realized when we checked into data sheets that it

31
00:02:46,280 --> 00:02:51,490
read LCD is connected to put f pin 1.

32
00:02:51,490 --> 00:02:55,750
So that's the one we have to initialize for our initialization.

33
00:02:55,810 --> 00:03:04,900
We are going to use something known as index an immediate addressing index addressing uses two or requires

34
00:03:04,900 --> 00:03:12,160
two registers one register points to a value and the value pointed to by this first register is then

35
00:03:12,190 --> 00:03:22,450
put into the second register and we do these two steps by using the L T R to load up code image ID address

36
00:03:22,450 --> 00:03:27,930
in uses the move up code to move the value into a register.

37
00:03:28,060 --> 00:03:33,180
So first as we said we have to activate the clock of the pot s here.

38
00:03:33,270 --> 00:03:39,340
Does the first and we have to do it and it said set number three we have to set it direction registers

39
00:03:39,370 --> 00:03:40,200
and then enable.

40
00:03:40,210 --> 00:03:44,620
Remember we're not doing this one here cos we're not using PD 7.

41
00:03:44,650 --> 00:03:51,130
So what we are going to do now is write out the content of our subroutine our subcutaneous code.

42
00:03:51,160 --> 00:03:52,600
Keep you f in it.

43
00:03:52,720 --> 00:04:02,310
So what we're going to do is load load the address of the clock into register 1 and we do this call

44
00:04:02,320 --> 00:04:20,560
in the r r one because system control our CDC keeping who on a school r remember addresses 32 bit large

45
00:04:20,650 --> 00:04:22,970
numbers here.

46
00:04:23,240 --> 00:04:32,780
Load R1 ecosystem control RC TCE TPA or R is pointing to the address I should tell you the name here

47
00:04:32,800 --> 00:04:41,680
system control RC KC TPA or R is a name you could think of it as a name was given to the numeric value

48
00:04:42,040 --> 00:04:44,120
of the address.

49
00:04:44,200 --> 00:04:50,080
Later on we would see how we assign this name to the 32 bits number before now now keep this name and

50
00:04:50,080 --> 00:04:56,860
now explain to you why we use in this long name which underscores rather than getting a simple name

51
00:04:56,890 --> 00:04:58,220
that we can remember.

52
00:04:58,600 --> 00:05:00,770
So let's move on now.

53
00:05:00,910 --> 00:05:07,420
We have our one pointing to the address of the system control register which is the clock register.

54
00:05:07,420 --> 00:05:14,290
Now we have to take the content at this address and put it into our cereal and we do that by invoking

55
00:05:14,360 --> 00:05:19,110
l the r r zero comma square brackets are 1.

56
00:05:19,890 --> 00:05:27,040
So now the content at this address pointed to by R1 is put into our zero.

57
00:05:27,070 --> 00:05:32,650
If you go back to the data sheet you would realize that they reset value of their system control our

58
00:05:32,760 --> 00:05:41,600
C GC GPI register as 0 0 0 0 0 with a series after the X currently.

59
00:05:41,770 --> 00:05:49,450
I'll tell you this value is put into our cereal so our cereal currently has this value in order to enable

60
00:05:49,450 --> 00:05:50,280
put F..

61
00:05:50,320 --> 00:05:59,560
We will have to enable bit 5 in the system control our CTC keep register and we can accomplish this

62
00:05:59,560 --> 00:06:14,620
by using something known as the or operator like this all power are our zero equals zero and number

63
00:06:14,620 --> 00:06:16,420
two zero.

64
00:06:16,600 --> 00:06:22,710
Here we say in our zero course Iris rule or zero x to zero.

65
00:06:22,750 --> 00:06:30,280
To further elaborate this let's take a break from your vision and see how this all operation changes

66
00:06:30,280 --> 00:06:30,970
the bit.
