Documente Academic
Documente Profesional
Documente Cultură
Abstract The paper details the activities done in using exceed preset threshold values and DMA request based
STML053R8T6 but to be used in Polling Mode. This entails the conversions. STM32 microcontrolles support two ADC
discussion about the functions of HAL_ADC_START,
HAL_ADC_PollForConversion, and HAL_ADC_GetValue. The conversion modes: regular and injected. Regular mode is what
last part of this paper involves the usage of potentiometer, and a we used to see in many types of microcontroller all channels
resistor to vary the analog voltage externally. The duty cycle can share same data register. Various regular modes can be
be compared through the simulations and through the help of
Analog Discovery. possible, like single, continuos and group. More interesting
here is group conversion where channels are specified to
Index Terms STML053R8T6, STM32CubeMX, convert where channels are specified to convert in round robin
DigilentWaveforms, ADC, polling mode, analog discovery, duty
cycle mode cycle through channels. Its up to you how you collect
data from register in time through conversion complete
I. INTRODUCTION
interrupt or using DMA. Conversion group can be configured
Analog-to-Digital Converter (ADC) is a peripheral that to cycle through maximum of 16 channels and order of
allows measuring the voltage (between 0 and Vref) on a certain channels can be also programmed they dont have to be in
input of the microcontroller and converting it into a number in order. Group can be programmed to convert continuously, and
between 0 and 2^N 1 where N is the ADC resolution. The discontinuously trigger by external trigger. In discontinuous
easiest way to experiment with an ADC is to connect it to a mode parts of group can be triggered to convert. For instance if
potentiometer which is a mechanically adjustable resistor. we select group to be 16 channels then we can program to
Connecting one side of the terminals of the potentiometer to convert first 3 channels on trigger, then wait for another trigger
the ground while the other one on the V cc pin, the voltage level and convert next three channels and so on. Another is the inject
will gradually change as the potentiometer knob is rotated. conversion mode. It can perform conversion of selected four
ADC resolution is one of the key factors to determine how channels. They have a priority over normal conversion group
precise the conversion can be. Faster conversion times can be scan. If normal group conversion is going on and injected
obtained by lowering the resolution. Its reference voltage is conversion is triggered, then normal conversion is halted, then
equal to supply voltage to Vdd pin. It may use successive injected conversion is performed. After that, normal conversion
approximation register principle wherein the conversion is is resumed. Injected conversion channels have their own result
performed in several steps. The number of conversion steps is registers and offset registers. Offset can store value that will be
equal to the number of bits in the ADC converter. Each step is automatically deducted from ADC result.
driven by the ADC clock. Each ADC clock produces one bit
from result to output. ADC internal design is a switched- II. GENERATING THE CODE
capacitor type. The configuration tab contains the analog group wherein the
ADC module has a separate supply which normally can be ADC is found. This is where the proper modes and other
connected to general MCU power supply. Also, it can have features will be set. After that, generating the codes would be
external reference source through Vref+ and Vref- that can be the next step.
brought through dedicated pins. In no special case analog
supply voltage may be reference internally. It can also be
performed in single or continuous mode for single channel,
scan through all channels, externally triggered conversion.
There is also an analog watchdog which can detect if voltage
III. RECTANGULAR WAVE WITH THREE DIFFERENT
DUTY CYCLES BASED ON ANALOG VALUE
Table 1. Ranges of analogValue with its duty cycle
Figure 3. codes for converting the gathered value into analog value
Fig. 3 shows the codes which is found under the main() Figure 5. analog voltage reading for 25% duty cycle
function. HAL_ADC_PollForConversion(&hadc, 1) is the one
that checks if the continuous conversion of regular channel is The recorded adcValue is 1266 and the analogValue is
finished. The second line of the code means that the adcValue 1.0202198022.
is what the HAL_ADC_GetValue will receive from hadc. The
last line of codes is the final value of the analogValue wherein
it is multiplied to 3.3 and divided by 4095.
The code was then downloaded. Another way in View is the
Live Watch. The adcValue and analogValue. A potentiometer
and a 1k resistor was connected. The potentiometer is across
the source, PA0 and ground. The connection forms a voltage
divider circuit where PA0 is in between.
Figure 6. rectangular wave with 50% duty cycle
Fig. 6 shows the rectangular waveform of the second range. it enables programmable priority levels and it is easy to use by
The duty cycle is likely the same with the off state. the programmers. NVIC supports vectored interrupt operations
so that there is no need to use another software to determine
which interrupt to serve.