Hello.
Welcome back.
So in this lesson we're going to create an ADC continuous conversion project to ADC continuous conversion
is actually used for much more rapid ADC conversion to a single mode converts in a very slow manner.
But if you want the conversion to be happening very rapidly let's say you're doing some form of signal
processing that requires your conversion to be going into microseconds.
Then it's better to use the ADC continuous conversion mode and if you need more information about continuous
conversion you can send the message.
So let's go to Cuba mix come over here and this where we left off with the other project.
I just click here to greet a new project and I'm going to select my board.
It's the SDM that's to a full board
Discovery.
Assume that two for this one here's my board and I'm still going to use my p zero which is connected
to a DC 1 0 0 0 0 pins and ADC 1 Over here enable the 0.
Once that is done I'll just come to the configurations and configure the ADC and this time we're going
to mess up with it a bit more first of all we need to scale down the clock.
We have to set a clock free clock pre-schooler here before we do that.
Let's verify the clock of the ATC from my User Guide.
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
2 is forty eight megahertz.
So this is actually the clock off my ADC because my ADC is connected to the APB to bus so I could either
keep that ATC clock or I could choose a preschooler in a pre-schooler basically a divider perhaps the
clock is too fast for my application perhaps a want day clock to run.
Perhaps I wanted to run out less a twenty four megahertz.
If that's the case I'll choose a pre-schooler of two but I don't want to.
I think twenty four megahertz is fine.
So I'm not just going to change this I'll leave the default setting which is a pre-schooler of two and
what we want is we want to enable continuous conversion over here so our community enable and data alignment.
We shall leave it right aligned a number of channels we have just one channel and if we want to customize
it any further.
In fact you can come over here we can expand the rank and choose to something time.
This one says the something time is three cycles but according to the data sheet there is a constant
twelve cycles that each ADC conversion takes.
So the value you see here is this value plus twelve cycles.
So our ADC is going to take 15 psychos to sample.
You can verify this from the data sheet of the MCU.
If you meet any difficulties in verifying that you can send me a message.
So this is it.
And it's as simple as this.
We just go and generally tell.
No I'm just going to click Okay over here and then come to code generation.
I'll expand this and then give my project a name I'll call it ADC continuous
and then I'll select my two chain which they call him to give version 5.
Then I'll click Okay over here and then it generates the code for me.
Once that is done I just click here to open my project.
And the project is opened.
Click it to rebuild it.
Oh
and it's finished rebuild and 0 0 warning so I just come over here and then send my debugger to run
and reset like this.
Okay.
And then okay now all we have to do is start the ATC like we did before and then after that we use the
get value to storage in the particular new instead of to a variable like we did.
So let's do that now show.
So this time rather than keeping it all in the one one loop we just want to start the ATC outside while
one loop and then just receive the converted value in the infinite while one loop is different from
what we did before what we did before we kept start and get to value both in the while one loop because
now a single conversion mode for continuous conversion mode is going to automatically convert rapidly
without we and every now and then.
So I'll just I'll just come here and use the same API we used ATC on the score ATC school starts
and we know it takes it takes one argument
the handle of the ADC then like we did before we're going to create a global grade book with 32 on the
school team sense of value and sense of value is going to hold it's going to get conversion I'm going
to come over NC so so funny because on a school ADC pone for conversion and then this one also takes
the ADC on classic argument and then the the time and then I'll just for one millisecond here and then
it should be fine.
I reviewed all and download onto my board and once that is done I can get before I just go to the debugger
and I'll add this to watch when the 1
and then I'll just disable hexadecimal display.
Now click here to learn the code and it's running and I'm moving my potential me to know yes the value
is stopped because we're using the wrong API here called ADC gets value only.
So I'll just change this to get value.
Of funny and I'll disable my debugger cause I'm still doing this in a debugger.
Come here now revealed 0 0 exited Tonga on a dude says I've got one area called ADC on a school rugby
and it doesn't take a timeout because it's continuous conversion.
You don't need to put timeouts there so we can verify this API by double clicking and come in here and
as you can see gets the converted file.
It takes just the adc can ADC Honduras argument so I'll rebuild this time it should be fine then I'll
download onto my board
once that is done I'll click over here to return to the De Backer
and then I'll click here to run my code and I'm moving my potential meta now.
And it's not change in values.
So the reason why it's stuck is because the conversion cycles we said was too little for the ADC.
In fact we demanded it to work too rapidly.
Let's go back to Cuba makes me show you what I mean.
Well I here we said something time should be three cycles.
So this is too too little.
The number of cycles for the ADC and we can change this to for eighty cycles and give him more time
to convert or we can change it from the code.
This time I'm going to show you how to change it from the code.
Sometimes when you do your Cuban make sets in and you want to quickly change something all of it is
generated in code.
So if you know that a particular parameter structure you know exactly what to change one way would be
to change it and Cuba makes and regenerates that code and then it would take effect here.
Another way is to come straight here.
So this where the code for the sub sampling time is as you can see over here says something time time
ADC sample time three cycles just like we chose over here.
Just like we chose three cycles.
So I'm just going to change this to the largest number available which is for 80 cycles.
I'm going to come over here and change this number three to four eighty and then we are still in the
debug fuse on the screen to exit and then redo it.
My project once that's done I'll just download onto my board then we'll return to the debugger.
I'll click here now or just click here to continuously run my code and move in a potential meta now.
And as you can see the funding is changing as I rotate the potential into I'm going to rotate it to
the lowest value.
You can see.
This is it.
And then I rotate it to the opposite direction.
The value increases as I move towards the opposite right.
So this is a DC continuous conversion.
If you have any questions or you need further elaboration don't hesitate to send me a message and I'll
see you in the next lesson.