OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 6963|回复: 1

大家帮我看看,我的AD程序一直卡在校准的位置,怎么破?

[复制链接]

1

主题

1

帖子

0

精华

新手入门

积分
25
金钱
25
注册时间
2015-6-15
在线时间
0 小时
发表于 2015-6-15 15:21:11 | 显示全部楼层 |阅读模式
5金钱
#include "bsp_adc.h"

void ADC1_IN1_Config(void)
{
         unsigned int  calibration_value = 0;
        GPIO_InitTypeDef    GPIO_InitStructure;
        ADC_InitTypeDef       ADC_InitStructure;
  ADC_CommonInitTypeDef ADC_CommonInitStructure;
        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
        
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 ;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
  GPIO_Init(GPIOA, &GPIO_InitStructure);
        
        


    /* Configure the ADC clock */
    RCC_ADCCLKConfig(RCC_ADC12PLLCLK_Div1);

    /* Enable ADC1 clock */
    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_ADC12, ENABLE);
        
        ADC_StructInit(&ADC_InitStructure);

        /* Calibration procedure */ 
        ADC_VoltageRegulatorCmd(ADC1, ENABLE);

        ADC_SelectCalibrationMode(ADC1, ADC_CalibrationMode_Single);
        ADC_StartCalibration(ADC1);
        
        while(ADC_GetCalibrationStatus(ADC1) != RESET );
        
        calibration_value = ADC_GetCalibrationValue(ADC1);

    /* Configure the ADC1 in continuous mode */
    ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent;                                                                    
    ADC_CommonInitStructure.ADC_Clock = ADC_Clock_AsynClkMode;                    
    ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled;             
    ADC_CommonInitStructure.ADC_DMAMode = ADC_DMAMode_OneShot;                  
    ADC_CommonInitStructure.ADC_TwoSamplingDelay = 0;      
    ADC_CommonInit(ADC1, &ADC_CommonInitStructure);

    ADC_InitStructure.ADC_ContinuousConvMode = ADC_ContinuousConvMode_Enable;
    ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b; 
    ADC_InitStructure.ADC_ExternalTrigConvEvent = ADC_ExternalTrigConvEvent_0;         
    ADC_InitStructure.ADC_ExternalTrigEventEdge = ADC_ExternalTrigEventEdge_None;
    ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
    ADC_InitStructure.ADC_OverrunMode = ADC_OverrunMode_Disable;
    ADC_InitStructure.ADC_AutoInjMode = ADC_AutoInjec_Disable;  
    ADC_InitStructure.ADC_NbrOfRegChannel = 1;
    ADC_Init(ADC1, &ADC_InitStructure);

     /* ADC1 regular channel5 configuration */ 
    ADC_RegularChannelConfig(ADC1, ADC_Channel_1, 1, ADC_SampleTime_181Cycles5);//2é?ùê±???a21.5us

    /* Enable EOC interrupt */
        ADC_ITConfig(ADC1, ADC_IT_EOC, ENABLE);

    /* Enable ADC1 */
    ADC_Cmd(ADC1, ENABLE);

    /* wait for ADRDY */
    while(ADC_GetFlagStatus(ADC1, ADC_FLAG_RDY) == RESET);
    GPIO_ResetBits(GPIOB,GPIO_Pin_3);
    /* ADC1 start Conversion */
//     ADC_StartConversion(ADC1);   
}
主函数调用ADC1_IN1_Config(),我用一个蜂鸣器来测试程序运行到哪里卡住了,结果程序一直卡在while(ADC_GetCalibrationStatus(ADC1) != RESET );这条AD校准语句上面,为何?

正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

8

主题

67

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
226
金钱
226
注册时间
2013-9-27
在线时间
26 小时
发表于 2015-6-16 14:04:10 | 显示全部楼层
你用的是F4还是F1的?F4的不需要校准
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-2-24 18:01

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表