stm32 的一个AD采集电阻的程序软件仿真没问题,硬件仿真就什么响应也没有

2019-03-23 19:09发布

int main(void)
{
#ifdef DEBUG
   debug();
#endif
    u32 ConversionValue;
   RCC_Configuration();    //使能外设时钟
GPIO_Configuration();
NVIC_Configuration();
//SMG_Init();
USART_Configuration(15200);
ADC_Configuration();
//  GPIO_Configuration();   //初始化GPIO管脚
               
   while (1)
   {
  printf(" 'B' ");
  printf(" www.A435.com");
  ConversionValue = (u32)Test_ConversionResult();
  printf(" i value is %d",ConversionValue);
void ADC_Configuration(void)
{
ADC_InitTypeDef ADC_InitStructure;
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;  //独立模式
ADC_InitStructure.ADC_ScanConvMode = ENABLE;  //连续多通道模式
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE; //连续转换模式
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;//不受外界决定
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; //数据右对齐
ADC_InitStructure.ADC_NbrOfChannel = 1;  //扫描通道数1
ADC_Init(ADC1,&ADC_InitStructure);
   /* Enable ADC1 reset calibaration register */   
   ADC_ResetCalibration(ADC1);  //重置ADC1的校准寄存器
   /* Check the end of ADC1 reset calibration register */
  // while(ADC_GetResetCalibrationStatus(ADC1));   //获取ADC重置校准寄存器的状态并等待其值变为0

   /* Start ADC1 calibaration */
   ADC_StartCalibration(ADC1);    //开始ADC1的校准状态
   /* Check the end of ADC1 calibration */
   while(ADC_GetCalibrationStatus(ADC1)); //获取ADC校准寄存器的状态并等待其值变为0(已完成校准)

        
ADC_RegularChannelConfig(ADC1, ADC_Channel_15, 1, ADC_SampleTime_55Cycles5);//ADC1,   
//ADC_RegularChannelConfig(ADC1, ADC_Channel_14, 2, ADC_SampleTime_1Cycles5);//ADC1,  如果定义2各通道的话
   
     /* Enable ADC1 DMA */
   ADC_DMACmd(ADC1, ENABLE);
    /* Enable ADC1 */
   ADC_Cmd(ADC1, ENABLE);

  /*****上网,我自己加的模拟看门狗语句*********/
    ADC_AnalogWatchdogSingleChannelConfig(ADC1, ADC_Channel_15);//第十五通道用模拟看门狗。
    ADC_AnalogWatchdogThresholdsConfig(ADC1, 0xbb8, 0x100);//设定模拟看门狗高低门槛。
    ADC_AnalogWatchdogCmd(ADC1, ADC_AnalogWatchdog_SingleRegEnable);//允许单通道加上模拟看门狗。
ADC_ITConfig(ADC1, ADC_IT_AWD, ENABLE);//允许模拟看门狗产生中断。
/* Start ADC1 Software Conversion */
   ADC_SoftwareStartConvCmd(ADC1, ENABLE);   //使能ADC1的软件转换启动功能

} 此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
5条回答
Li_Lei
1楼-- · 2019-03-24 02:04
 精彩回答 2  元偷偷看……
dapeng43
2楼-- · 2019-03-24 07:59
我一步一步调试,没有停,只是收到的字符是错误的,全是这种
Li_Lei
3楼-- · 2019-03-24 12:01
单步跟踪很难保证器件工作完全的正确,比如中断定时器dma等,
用断点截在dma的结束位置或者另外用一个数组存储中间状态,暂停后分析.
dapeng43
4楼-- · 2019-03-24 15:32
 精彩回答 2  元偷偷看……
dapeng43
5楼-- · 2019-03-24 20:09
再问一下,一般ADC的硬件都要怎么设置? 我这块是stm32红牛开发板,我只在stm3210x参考手册里看到他说,VREF-管脚必须和VSSA相连接。其他的没提,还需要其他的设置么?

一周热门 更多>