1
00:00:03,490 --> 00:00:04,110
Hello, fellas.

2
00:00:04,270 --> 00:00:04,870
Welcome back.

3
00:00:05,260 --> 00:00:10,030
In a section, we're going to learn how to create a D.C. project using the Cube remix.

4
00:00:10,390 --> 00:00:15,580
In this very first lesson, we shall learn how to do a single ADC conversion.

5
00:00:15,780 --> 00:00:17,860
So click over here to create a new project.

6
00:00:19,620 --> 00:00:20,920
And then I'll select my board.

7
00:00:21,490 --> 00:00:25,660
My board is the disco board and it's an F for board.

8
00:00:26,650 --> 00:00:29,000
And this one here is my particular microcontroller.

9
00:00:29,390 --> 00:00:30,580
DoubleClick to choose it.

10
00:00:34,120 --> 00:00:38,890
I just explained to her what I'm going to do, so I'm going to clear the pin out by clicking over her.

11
00:00:40,780 --> 00:00:46,780
And then everything is cleared now for my particular school board of court, just one ADC off court,

12
00:00:46,800 --> 00:00:49,770
just a DC one where I'm going to do it.

13
00:00:49,770 --> 00:00:55,200
So I'm going to come to a DC one and I've got the option to choose from the sixteen channels available.

14
00:00:55,770 --> 00:00:58,170
So I'm just going to start with Channel Zero over here.

15
00:00:58,330 --> 00:01:05,460
So like this in its chosen Channel Zero for me, once that is done, I'll just set my debugger and then

16
00:01:05,460 --> 00:01:07,940
go to configuration to configure the ADC.

17
00:01:08,430 --> 00:01:15,420
Click over here my depolarize the zero wire and once that is done, I just leave the clock configuration

18
00:01:15,660 --> 00:01:20,430
to the default setting and I'll come to configuration over here and then click here.

19
00:01:20,630 --> 00:01:24,600
ATC one for this example, we don't need a lot of changes actually.

20
00:01:25,200 --> 00:01:26,760
So I just click, OK.

21
00:01:27,580 --> 00:01:29,120
Now now generates the code.

22
00:01:29,220 --> 00:01:32,100
Come over here and I'll give my project a name.

23
00:01:33,700 --> 00:01:37,320
I'll call it ADC Single Conversion.

24
00:01:39,460 --> 00:01:42,940
And then I select my two chain, which is the column Decay.

25
00:01:43,640 --> 00:01:45,680
Now click, OK, it's January 10.

26
00:01:46,870 --> 00:01:50,440
And it's finished generates I'll just click over here to open a project.

27
00:01:53,690 --> 00:01:54,080
Right.

28
00:01:54,110 --> 00:01:54,800
It's opened.

29
00:01:55,100 --> 00:01:58,260
So what I want to do is click here to build the whole project.

30
00:02:04,130 --> 00:02:06,890
Once that is done, I can update my D-Box set in.

31
00:02:08,030 --> 00:02:10,510
I just click over here into this box here.

32
00:02:11,280 --> 00:02:11,690
Okay.

33
00:02:12,040 --> 00:02:12,470
Okay.

34
00:02:13,530 --> 00:02:19,660
And then open, what I want to do is start my ADC and start conversion.

35
00:02:19,750 --> 00:02:25,930
And when it finishes the conversion, I want to store the value in a variable which we will create later.

36
00:02:26,230 --> 00:02:27,150
So let's do that now.

37
00:02:27,670 --> 00:02:29,320
So just start the ADC.

38
00:02:29,440 --> 00:02:37,900
We need to use the ADC Start API and we can find the function here by clicking here and selecting the

39
00:02:37,900 --> 00:02:38,670
ADC module.

40
00:02:38,680 --> 00:02:41,890
Here we get a list of API is available to us.

41
00:02:42,460 --> 00:02:44,810
And this one here called How API Stuff.

42
00:02:45,060 --> 00:02:46,510
How ADC Start.

43
00:02:47,510 --> 00:02:48,140
This one here.

44
00:02:48,530 --> 00:02:50,840
It is you start so it can click here.

45
00:02:51,320 --> 00:02:57,590
This one here can read about it here says and it enables ADC starts conversion of regular channels.

46
00:02:58,220 --> 00:03:00,110
And what parameter does it take?

47
00:03:00,140 --> 00:03:03,440
It takes a pointer to the ADC handler structure.

48
00:03:04,220 --> 00:03:06,710
So we just copy this function.

49
00:03:07,950 --> 00:03:08,700
Bring it to Main.

50
00:03:10,760 --> 00:03:12,790
And then we start the ADC back, put in her.

51
00:03:13,910 --> 00:03:18,620
And then we just couldn't use the ADC handler, which is already declared here by Cuba, makes for us.

52
00:03:18,650 --> 00:03:19,700
So we just copy this.

53
00:03:20,330 --> 00:03:22,700
This is the argument of this function.

54
00:03:23,260 --> 00:03:24,500
Let's keep it in here like this.

55
00:03:24,830 --> 00:03:25,760
Put a semicolon.

56
00:03:26,490 --> 00:03:27,920
Now, I've started it, ADC.

57
00:03:28,640 --> 00:03:33,140
So what I want to do next is to pull for conversion, to get a conversion.

58
00:03:33,260 --> 00:03:36,080
We have to use the ADC pull for conversion API.

59
00:03:36,830 --> 00:03:37,580
And it's here.

60
00:03:39,040 --> 00:03:42,700
This one here, how ABC political conversion, so we can take a look at it.

61
00:03:43,200 --> 00:03:49,830
And it takes to document one is the ADC handler and then the other one is the time out.

62
00:03:50,620 --> 00:03:52,380
So I'm just going to copy this as well.

63
00:03:56,110 --> 00:03:57,580
And then poor for conversion.

64
00:03:58,930 --> 00:03:59,560
Copy this.

65
00:03:59,770 --> 00:04:01,060
Take it to my main function.

66
00:04:01,770 --> 00:04:07,500
Put it here and then I'm going to replace this with the NTC one.

67
00:04:09,520 --> 00:04:11,380
I'm going to give it time out of.

68
00:04:12,480 --> 00:04:18,990
In fact, we can give a time out of something as little as one millisecond and put a semicolon there.

69
00:04:20,310 --> 00:04:23,550
So once we've bought for conversion, we have to wait for it to convert.

70
00:04:23,600 --> 00:04:29,730
And we've given a time or two for a millisecond after this, we can use the whole ADC gets conversion,

71
00:04:29,850 --> 00:04:30,480
which is here.

72
00:04:32,200 --> 00:04:36,130
Get value, the ladies, he gets value less, click it and see what he says.

73
00:04:37,250 --> 00:04:43,370
Gets the converted value from data register off regular Chernow's in the parameter pointer to the ADC

74
00:04:43,400 --> 00:04:43,850
handler.

75
00:04:44,270 --> 00:04:48,150
What does a return and returns the converted value to can come over here.

76
00:04:48,190 --> 00:04:48,950
We copy this.

77
00:04:53,280 --> 00:04:54,350
Then we come over here.

78
00:04:55,980 --> 00:04:59,070
Then then we can say.

79
00:05:02,860 --> 00:05:05,500
Get value from the ADC handler like this.

80
00:05:05,800 --> 00:05:07,950
What we want is to keep all of this in the wild.

81
00:05:08,350 --> 00:05:10,260
And this one here returns the ADC file.

82
00:05:10,340 --> 00:05:15,070
So what I'm going to do is I'm going to create a global variable out here, up here to store the ADC

83
00:05:15,070 --> 00:05:22,630
value Grinch and make you into 32 on the school team, sense of value and sense of values going to half

84
00:05:22,630 --> 00:05:23,530
the ADC value.

85
00:05:23,590 --> 00:05:30,260
So I can come over here and see sense of value because all ADC gets value.

86
00:05:30,600 --> 00:05:34,180
And with this, we get the ADC value stored in this global variable for us.

87
00:05:34,420 --> 00:05:40,150
So we can just rebuild, download onto our board and then go to the debug view and put this in a watch

88
00:05:40,150 --> 00:05:42,190
window to see DADT value.

89
00:05:42,430 --> 00:05:48,650
So what I'm going to do is I'm going to connect an analog source to my ADC channel, which is B is you.

90
00:05:48,880 --> 00:05:51,490
What I've got here is a standard potential meta.

91
00:05:51,970 --> 00:05:57,370
I'm going to connect the middle leg of the potential meta to be issue the left leg to ground in the

92
00:05:57,370 --> 00:06:02,500
right like two plus five vote, and then I'm going to turn that potential meta.

93
00:06:02,860 --> 00:06:09,220
And we expect to see the analog value right here to change as I turn the potential meta.

94
00:06:09,610 --> 00:06:10,630
So let's do that now.

95
00:06:10,720 --> 00:06:15,640
And remember, if there's anything you do not understand, send me a message or leave it in the comments

96
00:06:15,640 --> 00:06:16,150
section.

97
00:06:16,480 --> 00:06:18,520
So I click to rebuild my project.

98
00:06:19,650 --> 00:06:22,730
Then once that is done, I'll just click over here to download onto my board.

99
00:06:25,790 --> 00:06:29,730
And once it is done, download it, I can click here to go to the DeBacker.

100
00:06:32,330 --> 00:06:39,050
What you want to do is double click, right, click on the sense of value variable and then to watch

101
00:06:39,050 --> 00:06:40,780
when to want to appear here.

102
00:06:40,870 --> 00:06:42,860
Once it appears we can right.

103
00:06:42,860 --> 00:06:47,270
Click over here to disable the hexadecimal display like this.

104
00:06:47,680 --> 00:06:50,060
And then I'm going to click here to run my code.

105
00:06:51,310 --> 00:06:59,150
And so this the middle value of my current potential meetup position, I'm going to rotate my potential

106
00:06:59,150 --> 00:07:04,810
with me to now, as you can see, I've rotated it to the on the other end of it.

107
00:07:04,990 --> 00:07:10,150
And the value is almost zero now if rotated to the opposite direction.

108
00:07:10,840 --> 00:07:14,530
So, yeah, this is a DC single single conversion mode.

109
00:07:15,000 --> 00:07:16,100
As you can see, it's working.

110
00:07:17,100 --> 00:07:19,750
Are fruitage headed to the other end again and the value down.

111
00:07:20,110 --> 00:07:20,780
So this is it.

112
00:07:20,940 --> 00:07:25,510
And the next lesson, we shall run another ADC application for continuous conversion.

113
00:07:25,870 --> 00:07:27,190
And I see you in the next lesson.
