1
00:00:04,060 --> 00:00:13,030
So now that we know where our lead is connected we can go ahead and initialize our parents and start

2
00:00:13,120 --> 00:00:14,730
right into our LCD.

3
00:00:15,550 --> 00:00:25,510
Let's delete this one here to initialize an input output port for general use requires usually three

4
00:00:25,510 --> 00:00:26,890
steps.

5
00:00:26,890 --> 00:00:31,960
The first step we have to activate that clock off the port in the iris UGC.

6
00:00:31,960 --> 00:00:40,880
Keep it eye or register and if we are using PD 7 we would have to unlock the pin with a particular code.

7
00:00:40,900 --> 00:00:45,310
This is only required if we are using PD 7 which we are not.

8
00:00:45,670 --> 00:00:52,850
So we would after that set the direction of the pin in that the eye register.

9
00:00:53,110 --> 00:00:59,960
And when we set it to zero we tell the microcontroller this pin is an input.

10
00:01:00,040 --> 00:01:05,530
And when we set it to one standard microcontroller is told this pin is an output.

11
00:01:05,650 --> 00:01:12,940
So we would have to set it to 1 in order to tell it of microcontroller or LCD is an output which is

12
00:01:13,870 --> 00:01:18,270
after that we would have to enable the pin India enabler register.

13
00:01:19,080 --> 00:01:27,590
And after with initialize we would have to write to the pin through the GP 8 0 data register.

14
00:01:27,700 --> 00:01:37,180
So these pages here are pages in the data sheet that we can refer to and see how to enable these things.

15
00:01:37,270 --> 00:01:41,340
Don't worry you wouldn't have to go through this long process all the time.

16
00:01:41,530 --> 00:01:46,760
We are dealing with a fundamentalist task while we're going through every my new step.

17
00:01:46,820 --> 00:01:52,180
So as you type know what it means in later videos you wouldn't have to do this.

18
00:01:52,210 --> 00:01:55,780
You just have to import a file containing all of this information.

19
00:01:55,870 --> 00:02:00,490
You wouldn't have to go to the data sheet for every program.

20
00:02:00,610 --> 00:02:09,070
So if you've not yet downloaded a data sheet you can copy and paste this link into your address bar

21
00:02:09,100 --> 00:02:13,230
and hit enter and you would find a data sheet in there.

22
00:02:13,240 --> 00:02:22,430
I have my open here and as we said Yeah it's the data sheet.

23
00:02:22,550 --> 00:02:25,940
This one should look for the data sheet we set.

24
00:02:25,940 --> 00:02:31,380
Page 340 gives us the information about the RC keep a register.

25
00:02:31,640 --> 00:02:39,670
So a quick way of doing that is just come in here and write in 340 and we are here.

26
00:02:39,680 --> 00:02:41,270
So let's see what he says.

27
00:02:41,330 --> 00:02:49,730
The RC Casey keep a register provides software the capability to enable and disable GPO modules in run

28
00:02:49,730 --> 00:02:50,240
mode.

29
00:02:50,450 --> 00:02:52,100
Blah blah blah.

30
00:02:52,100 --> 00:03:01,340
What this means is when enabled and module is provided a clock and accesses to the modules registers

31
00:03:01,450 --> 00:03:07,460
are allowed to in order to be able to control the registers of a particular module.

32
00:03:07,460 --> 00:03:14,330
In this case a port in order to control the registers of port f we would have to activate the clock

33
00:03:14,390 --> 00:03:17,450
of port F and let's see the register here.

34
00:03:17,510 --> 00:03:27,120
You remember what we said registers are 32 bits and we can think of a bit as a demarcation and at draw

35
00:03:27,230 --> 00:03:35,130
we said we can think of registers as drawers and destroy has a two demarcations so you can think of

36
00:03:35,130 --> 00:03:35,240
four.

37
00:03:35,240 --> 00:03:38,570
Here we have 0 1 2 3 4 5.

38
00:03:38,900 --> 00:03:40,340
Or do we 2 3 1.

39
00:03:40,340 --> 00:03:41,680
And this makes the two.

40
00:03:41,750 --> 00:03:45,650
And let's see what each bit is used for.

41
00:03:45,830 --> 00:03:50,050
We have bit 6 3 to 2 1 as reserved.

42
00:03:50,060 --> 00:03:51,910
This is 6 to 1.

43
00:03:51,940 --> 00:03:56,380
We don't touch here we don't use yet reserved when we have 0.

44
00:03:56,420 --> 00:03:58,800
Let's see not this stuff from 5.

45
00:03:59,100 --> 00:03:59,590
Let's go.

46
00:03:59,600 --> 00:04:06,140
According to the document we have bit 5 year bit 5 is used to control pot.

47
00:04:06,140 --> 00:04:08,280
F you see what we have here.

48
00:04:08,660 --> 00:04:15,440
So there's the bit we would have to enable in the register to get access to the to the registers of

49
00:04:15,440 --> 00:04:15,810
pot.

50
00:04:15,840 --> 00:04:18,510
F bits for it's for pot e.

51
00:04:18,590 --> 00:04:23,110
We're not using this in later videos we would use different ports.

52
00:04:23,270 --> 00:04:32,210
So for put f we would have to activate the clock in bit 5 if 0 GPA or put F is disabled if 1 enable

53
00:04:32,240 --> 00:04:35,920
and provide a clock to keep yo pots F in run mode.

54
00:04:35,960 --> 00:04:39,730
So what we want is to enable and provide a clock to it.

55
00:04:39,800 --> 00:04:44,630
So we would have to set it's 5 to 1.

56
00:04:45,200 --> 00:04:51,790
So over here it says the next thing we would need to do is set the direction of the pin in the D I R

57
00:04:51,800 --> 00:05:00,500
register and we can find that in Page 6 6 3 window unlocking PD 7 cos we're not using PD 7.

58
00:05:00,560 --> 00:05:09,370
Step 3 says we set a direction that I R so we can find out in Page 6 6 3 that's come here.

59
00:05:09,360 --> 00:05:14,670
Data Sheet check 6 6 3 what we have here.

60
00:05:14,680 --> 00:05:24,890
Keep an eye o direction register and what us the direction register say 0 through 7 usable and a through

61
00:05:24,890 --> 00:05:26,740
thirty one reserved.

62
00:05:26,800 --> 00:05:29,410
And what does it say.

63
00:05:29,600 --> 00:05:37,120
It says if 0 corresponding PIN is an input if one corresponding PIN is an output like we said earlier.

64
00:05:37,190 --> 00:05:41,450
So we would have to set it to 1 to say as an output.

65
00:05:41,450 --> 00:05:47,260
After that we would have to set the date and register we would have to set the digital enabled register

66
00:05:47,510 --> 00:05:51,230
and we can find that on page 6 8 2.

67
00:05:51,320 --> 00:05:55,990
So we come back here and we come straight to 6 8 to

68
00:05:59,330 --> 00:06:09,170
enter and we have keep people digital and enable unless you want this tells us just like the DJI are

69
00:06:09,230 --> 00:06:15,800
the hospital eight through thirty one we served and 0 through 7 usable.

70
00:06:15,890 --> 00:06:22,890
These are the digital enables and 0 implies the pin is disabled and one implies it enabled.

71
00:06:22,910 --> 00:06:27,550
So we have to enable this pin to be able to use a.
