我是靠谱客的博主 隐形眼神,最近开发中收集的这篇文章主要介绍STM32G030系列ADC校准,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

用LL库编写STM32G030F6P6的ADC功能时,需要校准ADC,使用下列代码校准

LL_ADC_EnableInternalRegulator(ADC1);
delay_us(100);
LL_ADC_StartCalibration(ADC1); 
while( LL_ADC_IsCalibrationOnGoing(ADC1)); 
LL_ADC_Enable(ADC1);

手册中的相关描述

14.3.3 Calibration (ADCAL) The ADC has a calibration feature. During the procedure, the ADC calculates a calibration factor which is
internally applied to the ADC until the next ADC power-off. The
application must not use the ADC during calibration and must wait
until it is complete. Calibration should be performed before starting
A/D conversion. It removes the offset error which may vary from chip
to chip due to process variation. The calibration is initiated by
software by setting bit ADCAL = 1. Calibration can only be initiated
when the ADC voltage regulator is enabled (ADVREGEN = 1 and
tADCVREG_SETUP has elapsed) and the ADC is disabled (when ADEN = 0).
ADCAL bit stays at 1 during all the calibration sequence. It is then
cleared by hardware as soon the calibration completes. After this,
the calibration factor can be read from the ADC_DR register (from bits
6 to 0). The internal analog calibration is kept if the ADC is
disabled (ADEN = 0). When the ADC operating conditions change (VDDA
changes are the main contributor to ADC offset variations and
temperature change to a lesser extend), it is recommended to re-run a
calibration cycle. The calibration factor is lost in the following
cases: • The power supply is removed from the ADC (for example when
the product enters STANDBY or VBAT mode) • The ADC peripheral is
reset. The calibration factor is lost each time power is removed from
the ADC (for example when the product enters Standby or VBAT mode).
Still, it is possible to save and restore the calibration factor by
software to save time when re-starting the ADC (as long as temperature
and voltage are stable during the ADC power-down). The calibration
factor can be written if the ADC is enabled but not converting (ADEN =
1 and ADSTART = 0). Then, at the next start of conversion, the
calibration factor is automatically injected into the analog ADC.
This loading is transparent and does not add any cycle latency to the
start of the conversion. Software calibration procedure

  1. Ensure that ADEN = 0, ADVREGEN = 1 and DMAEN = 0.
  2. Set ADCAL = 1.
  3. Wait until ADCAL = 0 (or until EOCAL = 1). This can be handled by interrupt if the interrupt is enabled by setting the EOCALIE bit in
    the ADC_IER register
  4. The calibration factor can be read from bits 6:0 of ADC_DR or ADC_CALFACT registers. Calibration factor forcing Software Procedure
  5. Ensure that ADEN = 1 and ADSTART = 0 (ADC started with no conversion ongoing)
  6. Write ADC_CALFACT with the saved calibration factor
  7. The calibration factor is used as soon as a new conversion is launched.

最后

以上就是隐形眼神为你收集整理的STM32G030系列ADC校准的全部内容,希望文章能够帮你解决STM32G030系列ADC校准所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(82)

评论列表共有 0 条评论

立即
投稿
返回
顶部