[其他ST产品] 帮忙看看STR736的ADC转换

[复制链接]
2894|0
 楼主| crazyjack 发表于 2007-12-17 19:39 | 显示全部楼层 |阅读模式
现在搞个AD转换老是不行,得出的结果一直是0
下面是我的程序,哪位大侠帮忙看下问题出在哪里,谢谢了

/*---------------------------------CMU---------------------------------------*/
  /* CMU Initialization */
  CMU_DeInit( );
  CMU_StructInit(&CMU_InitStructure);
  /* Enable the external Quartz clock source */
  CMU_InitStructure.CMU_CKSEL0 = CMU_CKSEL0_CKOSC;
  CMU_Init(&CMU_InitStructure);

/*-------------------------------------PRCCU---------------------------------*/
  /* PRCCU Initialization */
  PRCCU_DeInit();
  PRCCU_StructInit(&PRCCU_InitStructure);
  /* Set MCLK = 8MHz */
  PRCCU_InitStructure.PRCCU_DIV2 = DISABLE;
  PRCCU_InitStructure.PRCCU_PLLDIV = PRCCU_PLLDIV_6;
  PRCCU_InitStructure.PRCCU_PLLMUL =PRCCU_PLLMUL_12;
  PRCCU_Init(&PRCCU_InitStructure);
  /*---------------------------------ADC---------------------------------------*/
  /* ADC Clock Enable */
  CFG_PeripheralClockConfig(CFG_CLK_ADC, ENABLE);
  /* ADC Configuration */
  ADC_StructInit(&ADC_InitStructure);
  ADC_InitStructure.ADC_Calibration = ADC_Calibration_ON;
  ADC_InitStructure.ADC_CalibAverage = ADC_CalibAverage_Enable;
  ADC_InitStructure.ADC_AutoClockOff = ADC_AutoClockOff_Disable ;
  ADC_InitStructure.ADC_ConversionMode = ADC_ConversionMode_Scan;
  ADC_InitStructure.ADC_SamplingPrescaler = 0x7;
  ADC_InitStructure.ADC_ConversionPrescaler = 0x7;
  ADC_InitStructure.ADC_FirstChannel = ADC_CHANNEL13 ;
  ADC_InitStructure.ADC_ChannelNumber = 1;
  ADC_Init (&ADC_InitStructure);

void main()
{
 ADC_InitTypeDef     ADC_InitStructure;

#ifdef DEBUG
    debug();
#endif
 static   u16 value=0;
      
while (1)
{     ADC_Cmd(ENABLE);
     ADC_ConversionCmd(ADC_ConversionStart);
     while(ADC_FlagStatus (ADC_FLAG_EOC)==0)
         NOP;
     ADC_ConversionCmd (ADC_ConversionStop);

     value=ADC_GetConversionValue(ADC_CHANNEL13);
       ADC_FlagClear(ADC_FLAG_EOC);
     

    if((value&0x03ff)> 0x01)
       GPIO_BitWrite( GPIO1,  POWER_ON, Bit_RESET); 
      delay_us(1000);
 }
 
}

程序流程就是这样的,帮忙看看
谢谢了
您需要登录后才可以回帖 登录 | 注册

本版积分规则

4

主题

9

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部