1
00:00:03,530 --> 00:00:04,040
Hello.

2
00:00:04,100 --> 00:00:04,790
Welcome back.

3
00:00:04,790 --> 00:00:12,560
So in this lesson we're going to create an ADC continuous conversion project to ADC continuous conversion

4
00:00:12,980 --> 00:00:20,180
is actually used for much more rapid ADC conversion to a single mode converts in a very slow manner.

5
00:00:20,210 --> 00:00:25,580
But if you want the conversion to be happening very rapidly let's say you're doing some form of signal

6
00:00:25,580 --> 00:00:29,880
processing that requires your conversion to be going into microseconds.

7
00:00:30,410 --> 00:00:36,440
Then it's better to use the ADC continuous conversion mode and if you need more information about continuous

8
00:00:36,440 --> 00:00:38,120
conversion you can send the message.

9
00:00:38,330 --> 00:00:44,610
So let's go to Cuba mix come over here and this where we left off with the other project.

10
00:00:44,610 --> 00:00:50,340
I just click here to greet a new project and I'm going to select my board.

11
00:00:50,340 --> 00:00:52,270
It's the SDM that's to a full board

12
00:00:55,090 --> 00:00:56,630
Discovery.

13
00:00:56,780 --> 00:01:02,860
Assume that two for this one here's my board and I'm still going to use my p zero which is connected

14
00:01:02,890 --> 00:01:11,080
to a DC 1 0 0 0 0 pins and ADC 1 Over here enable the 0.

15
00:01:11,140 --> 00:01:18,460
Once that is done I'll just come to the configurations and configure the ADC and this time we're going

16
00:01:18,460 --> 00:01:23,910
to mess up with it a bit more first of all we need to scale down the clock.

17
00:01:23,980 --> 00:01:27,720
We have to set a clock free clock pre-schooler here before we do that.

18
00:01:27,730 --> 00:01:31,780
Let's verify the clock of the ATC from my User Guide.

19
00:01:31,780 --> 00:01:40,720
I know my ADC is connected to APB 2 so if I come here this the clock of a people to the clock of APB

20
00:01:40,720 --> 00:01:42,910
2 is forty eight megahertz.

21
00:01:42,910 --> 00:01:50,920
So this is actually the clock off my ADC because my ADC is connected to the APB to bus so I could either

22
00:01:50,950 --> 00:01:59,170
keep that ATC clock or I could choose a preschooler in a pre-schooler basically a divider perhaps the

23
00:01:59,170 --> 00:02:04,030
clock is too fast for my application perhaps a want day clock to run.

24
00:02:04,030 --> 00:02:07,030
Perhaps I wanted to run out less a twenty four megahertz.

25
00:02:07,060 --> 00:02:12,760
If that's the case I'll choose a pre-schooler of two but I don't want to.

26
00:02:12,950 --> 00:02:15,550
I think twenty four megahertz is fine.

27
00:02:15,560 --> 00:02:20,820
So I'm not just going to change this I'll leave the default setting which is a pre-schooler of two and

28
00:02:20,830 --> 00:02:28,440
what we want is we want to enable continuous conversion over here so our community enable and data alignment.

29
00:02:28,450 --> 00:02:34,720
We shall leave it right aligned a number of channels we have just one channel and if we want to customize

30
00:02:34,720 --> 00:02:35,860
it any further.

31
00:02:35,860 --> 00:02:41,590
In fact you can come over here we can expand the rank and choose to something time.

32
00:02:41,620 --> 00:02:47,170
This one says the something time is three cycles but according to the data sheet there is a constant

33
00:02:47,200 --> 00:02:50,180
twelve cycles that each ADC conversion takes.

34
00:02:50,230 --> 00:02:55,120
So the value you see here is this value plus twelve cycles.

35
00:02:55,120 --> 00:02:59,440
So our ADC is going to take 15 psychos to sample.

36
00:02:59,500 --> 00:03:02,740
You can verify this from the data sheet of the MCU.

37
00:03:02,740 --> 00:03:06,800
If you meet any difficulties in verifying that you can send me a message.

38
00:03:07,240 --> 00:03:08,080
So this is it.

39
00:03:08,680 --> 00:03:10,390
And it's as simple as this.

40
00:03:10,390 --> 00:03:12,150
We just go and generally tell.

41
00:03:12,160 --> 00:03:17,240
No I'm just going to click Okay over here and then come to code generation.

42
00:03:17,270 --> 00:03:22,520
I'll expand this and then give my project a name I'll call it ADC continuous

43
00:03:25,100 --> 00:03:29,250
and then I'll select my two chain which they call him to give version 5.

44
00:03:29,390 --> 00:03:33,290
Then I'll click Okay over here and then it generates the code for me.

45
00:03:33,590 --> 00:03:36,370
Once that is done I just click here to open my project.

46
00:03:41,950 --> 00:03:44,070
And the project is opened.

47
00:03:44,070 --> 00:03:45,130
Click it to rebuild it.

48
00:03:45,180 --> 00:03:45,480
Oh

49
00:03:49,380 --> 00:03:56,810
and it's finished rebuild and 0 0 warning so I just come over here and then send my debugger to run

50
00:03:56,840 --> 00:03:58,870
and reset like this.

51
00:03:59,110 --> 00:03:59,750
Okay.

52
00:03:59,830 --> 00:04:06,920
And then okay now all we have to do is start the ATC like we did before and then after that we use the

53
00:04:07,010 --> 00:04:12,770
get value to storage in the particular new instead of to a variable like we did.

54
00:04:12,770 --> 00:04:14,980
So let's do that now show.

55
00:04:15,170 --> 00:04:20,870
So this time rather than keeping it all in the one one loop we just want to start the ATC outside while

56
00:04:20,900 --> 00:04:27,530
one loop and then just receive the converted value in the infinite while one loop is different from

57
00:04:27,530 --> 00:04:34,100
what we did before what we did before we kept start and get to value both in the while one loop because

58
00:04:34,100 --> 00:04:40,520
now a single conversion mode for continuous conversion mode is going to automatically convert rapidly

59
00:04:40,550 --> 00:04:43,470
without we and every now and then.

60
00:04:43,880 --> 00:04:52,070
So I'll just I'll just come here and use the same API we used ATC on the score ATC school starts

61
00:04:55,130 --> 00:04:59,450
and we know it takes it takes one argument

62
00:05:03,830 --> 00:05:10,680
the handle of the ADC then like we did before we're going to create a global grade book with 32 on the

63
00:05:10,690 --> 00:05:17,510
school team sense of value and sense of value is going to hold it's going to get conversion I'm going

64
00:05:17,510 --> 00:05:29,300
to come over NC so so funny because on a school ADC pone for conversion and then this one also takes

65
00:05:29,300 --> 00:05:35,480
the ADC on classic argument and then the the time and then I'll just for one millisecond here and then

66
00:05:35,630 --> 00:05:37,130
it should be fine.

67
00:05:37,130 --> 00:05:47,710
I reviewed all and download onto my board and once that is done I can get before I just go to the debugger

68
00:05:48,130 --> 00:05:50,020
and I'll add this to watch when the 1

69
00:05:53,420 --> 00:05:56,170
and then I'll just disable hexadecimal display.

70
00:05:56,270 --> 00:06:02,680
Now click here to learn the code and it's running and I'm moving my potential me to know yes the value

71
00:06:02,680 --> 00:06:07,540
is stopped because we're using the wrong API here called ADC gets value only.

72
00:06:07,750 --> 00:06:10,270
So I'll just change this to get value.

73
00:06:10,530 --> 00:06:18,910
Of funny and I'll disable my debugger cause I'm still doing this in a debugger.

74
00:06:18,910 --> 00:06:33,690
Come here now revealed 0 0 exited Tonga on a dude says I've got one area called ADC on a school rugby

75
00:06:35,220 --> 00:06:39,150
and it doesn't take a timeout because it's continuous conversion.

76
00:06:39,160 --> 00:06:45,060
You don't need to put timeouts there so we can verify this API by double clicking and come in here and

77
00:06:45,100 --> 00:06:47,210
as you can see gets the converted file.

78
00:06:47,250 --> 00:06:56,250
It takes just the adc can ADC Honduras argument so I'll rebuild this time it should be fine then I'll

79
00:06:56,250 --> 00:06:57,330
download onto my board

80
00:07:02,390 --> 00:07:05,330
once that is done I'll click over here to return to the De Backer

81
00:07:10,440 --> 00:07:15,750
and then I'll click here to run my code and I'm moving my potential meta now.

82
00:07:17,280 --> 00:07:19,180
And it's not change in values.

83
00:07:19,480 --> 00:07:26,190
So the reason why it's stuck is because the conversion cycles we said was too little for the ADC.

84
00:07:26,380 --> 00:07:29,410
In fact we demanded it to work too rapidly.

85
00:07:29,410 --> 00:07:32,570
Let's go back to Cuba makes me show you what I mean.

86
00:07:32,570 --> 00:07:37,170
Well I here we said something time should be three cycles.

87
00:07:37,300 --> 00:07:39,670
So this is too too little.

88
00:07:39,670 --> 00:07:46,420
The number of cycles for the ADC and we can change this to for eighty cycles and give him more time

89
00:07:46,420 --> 00:07:48,830
to convert or we can change it from the code.

90
00:07:48,940 --> 00:07:52,350
This time I'm going to show you how to change it from the code.

91
00:07:52,450 --> 00:07:57,850
Sometimes when you do your Cuban make sets in and you want to quickly change something all of it is

92
00:07:57,850 --> 00:07:58,920
generated in code.

93
00:07:58,930 --> 00:08:04,630
So if you know that a particular parameter structure you know exactly what to change one way would be

94
00:08:04,630 --> 00:08:09,260
to change it and Cuba makes and regenerates that code and then it would take effect here.

95
00:08:09,340 --> 00:08:11,860
Another way is to come straight here.

96
00:08:11,860 --> 00:08:18,350
So this where the code for the sub sampling time is as you can see over here says something time time

97
00:08:18,380 --> 00:08:23,430
ADC sample time three cycles just like we chose over here.

98
00:08:23,620 --> 00:08:25,280
Just like we chose three cycles.

99
00:08:25,840 --> 00:08:32,320
So I'm just going to change this to the largest number available which is for 80 cycles.

100
00:08:32,360 --> 00:08:37,840
I'm going to come over here and change this number three to four eighty and then we are still in the

101
00:08:37,850 --> 00:08:41,020
debug fuse on the screen to exit and then redo it.

102
00:08:41,020 --> 00:08:47,920
My project once that's done I'll just download onto my board then we'll return to the debugger.

103
00:08:47,920 --> 00:08:55,210
I'll click here now or just click here to continuously run my code and move in a potential meta now.

104
00:08:55,220 --> 00:09:01,300
And as you can see the funding is changing as I rotate the potential into I'm going to rotate it to

105
00:09:01,300 --> 00:09:02,270
the lowest value.

106
00:09:02,340 --> 00:09:03,570
You can see.

107
00:09:03,580 --> 00:09:04,090
This is it.

108
00:09:04,090 --> 00:09:06,590
And then I rotate it to the opposite direction.

109
00:09:06,640 --> 00:09:10,540
The value increases as I move towards the opposite right.

110
00:09:10,570 --> 00:09:13,060
So this is a DC continuous conversion.

111
00:09:13,090 --> 00:09:19,120
If you have any questions or you need further elaboration don't hesitate to send me a message and I'll

112
00:09:19,120 --> 00:09:20,800
see you in the next lesson.
