Escolar Documentos
Profissional Documentos
Cultura Documentos
The injected group has priority over the regular channel group. It interrupts the conversion of
the current channel in the regular channel group.
Single conversion mode
• Simplest of all mode
• ADC performs single conversion of a single channel and stops after
completion of the conversion
Single conversion mode (cont.)
Single conversion mode can be start by :
• setting the SWSTART bit in the ADC_CR2 register (for a regular channel only)
• setting the JSWSTART bit (for an injected channel)
• external trigger (for a regular or injected channel)
• Set the regular channel sequence length to 1 in ADC_SQR1, and specify the channel
in SQx in ADC_SQR1
Auto injection
Triggered injection
1. Go to ADC configuration,
ensure that the number of conversion
is 1 as we only converting 1 channel
2. Select regular conversion launched by
software. We will initiate conversion by
setting SWSTART bit to 1.
3. Select channel Temperature sensor.
4. Sampling time shouldn’t greater than min
sampling time in the datasheets, which is
10us
5. To enable single conversion mode, disable
the continuous conversion mode.
Calculation for sampling time
Note: to calculate the exact temperature, use the equation in the first page of playing
with built in temperature sensor.
Playing with built in temperature sensor (cont.)
Continuous Conversion Mode
• EXTSEL and JEXTSEL control bits are used to select 16 possible events that
trigger
Regular channel
Conversion on external trigger and trigger polarity (cont.)
Injected channel
Conversion on external trigger and trigger polarity (cont.)
Programming with cubemx
1. Select trigger conversion source as exti line11, and trigger detection as rising or falling
edge.
2. Don’t forget also to enable EXTI interrupts on NVIC configuration.
3. Use the same code as before, but now only exti interrupt could initiate ADC conversion.
Conversion on external trigger and trigger polarity (cont.)
External trigger on EXTI line11 for regular channel
Programming without cubemx
• The exti channel select is PF11
Interrupts on ADC
• Be able to generate interrupts after EOC or EOS bit is set by either setting
EOCIE bit (for regular channel) or JEOCIE bit (for injected channel).
• Converts an injected group of channels. Trigger sources comes from JEXTSEL on ADC1.
A simultaneous trigger source is provided to the other ADC.
Dual ADC
Multi ADC mode cont.
Triple ADC
Multi ADC mode cont.
Interleaved mode
• This mode can be started only on a regular group (usually one channel). The external
trigger source also comes from the regular channel multiplexer of ADC1.
• After an external trigger occurs:
- ADC1 starts immediately
- ADC2 starts after a delay of several ADC clock cycles
• The minimum delay can be configured in DELAY bits in ADC_CCR register.
• The conversion will repeat itself if CONT bit is set.
Triple ADC
Multi ADC mode cont.
Alternate trigger mode