打印

关于ADC3的Calibration

[复制链接]
2816|6
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
Tenant_2013|  楼主 | 2013-4-17 19:43 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
ADC1、ADC2、ADC3设置之后,进行Calibration:

  /* ADC1: Enable & Calibration */
  /* Enable ADC1 */
  ADC_Cmd(ADC1, ENABLE);

  /* Enable ADC1 reset calibration register */   
  ADC_ResetCalibration(ADC1);
  /* Check the end of ADC1 reset calibration register */
  while(ADC_GetResetCalibrationStatus(ADC1));

  /* Start ADC1 calibration */
  ADC_StartCalibration(ADC1);
  /* Check the end of ADC1 calibration */
  while(ADC_GetCalibrationStatus(ADC1));


  /* ADC2: Enable & Calibration */
  /* Enable ADC2 */
  ADC_Cmd(ADC2, ENABLE);

  /* Enable ADC2 reset calibration register */   
  ADC_ResetCalibration(ADC2);
  /* Check the end of ADC2 reset calibration register */
  while(ADC_GetResetCalibrationStatus(ADC2));

  /* Start ADC2 calibration */
  ADC_StartCalibration(ADC2);
  /* Check the end of ADC2 calibration */
  while(ADC_GetCalibrationStatus(ADC2));


  /* ADC3: Enable & Calibration */
  /* Enable ADC3 */
  ADC_Cmd(ADC3, ENABLE);

  /* Enable ADC3 reset calibration register */   
  ADC_ResetCalibration(ADC3);
  /* Check the end of ADC3 reset calibration register */
  while(ADC_GetResetCalibrationStatus(ADC3));

  /* Start ADC3 calibration */
  ADC_StartCalibration(ADC3);
  /* Check the end of ADC3 calibration */
  while(ADC_GetCalibrationStatus(ADC3));

Run,然后就在  while(ADC_GetResetCalibrationStatus(ADC3));上死循环了。

查看stm32f10x_adc.c,找到ADC_ResetCalibrationADC_GetResetCalibrationStatus

void ADC_ResetCalibration(ADC_TypeDef* ADCx)
{
  /* Check the parameters */
  assert_param(IS_ADC_ALL_PERIPH(ADCx));
  /* Resets the selected ADC calibration registers */  
  ADCx->CR2 |= CR2_RSTCAL_Set;
}

FlagStatus ADC_GetResetCalibrationStatus(ADC_TypeDef* ADCx)
{
  FlagStatus bitstatus = RESET;
  /* Check the parameters */
  assert_param(IS_ADC_ALL_PERIPH(ADCx));
  /* Check the status of RSTCAL bit */
  if ((ADCx->CR2 & CR2_RSTCAL_Set) != (uint32_t)RESET)
  {
    /* RSTCAL bit is set */
    bitstatus = SET;
  }
  else
  {
    /* RSTCAL bit is reset */
    bitstatus = RESET;
  }
  /* Return the RSTCAL bit status */
  return  bitstatus;
}

用Watchwindow查看,发现:
ADC1的CR2末四位:0011,其中RSTCAL为0;
ADC2的CR2末四位:0011,其中RSTCAL为0;
ADC3的CR2末四位:1011,其中RSTCAL为1.

Reference manual关于RSTCAL位的说明如下:This bit is set by software and cleared by hardware. It is cleared after the calibration registers are initialized.
就是说ADC3的Calibration功能在“ADCx->CR2 |= CR2_RSTCAL_Set;”之后没有“cleared by hardware”

然而,ADC1、ADC2均没有出现这个问题,实在感到不解。本人初学,望各位大侠指导一下。
沙发
airwill| | 2013-4-17 20:44 | 只看该作者
什么芯片都没有说,103xC 吧? ADC3 在手册上没有说这个方面有不同呀

使用特权

评论回复
板凳
airwill| | 2013-4-17 20:55 | 只看该作者
本帖最后由 airwill 于 2013-4-17 22:07 编辑

什么芯片都没有说,103xC 吧?还有 STM32F2X, 4X, 有 ADC3, 不过好象没有 calibrate 位。查一下手册看看

使用特权

评论回复
地板
Tenant_2013|  楼主 | 2013-4-17 21:12 | 只看该作者
是STM32F103RB,突然发现,只有2个ADC。。。

感谢大家关心!

使用特权

评论回复
5
Tenant_2013|  楼主 | 2013-4-17 21:17 | 只看该作者
airwill 发表于 2013-4-17 20:55
什么芯片都没有说,103xC 吧? ADC3 在手册上没有说这个方面有不同呀

这个问题纠结了我一天,程序查了不知道多少遍……令人吐血的毕业设计啊……

多谢前辈提醒啊!

使用特权

评论回复
6
ahpuhts| | 2013-8-4 14:23 | 只看该作者
对啊

使用特权

评论回复
7
hkcj| | 2013-8-4 19:01 | 只看该作者
问题解决了就好   还是版主给力  不错   

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

3

主题

7

帖子

0

粉丝