打印
[应用相关]

请教BZ,ADC配置中“信道音序器级别”?

[复制链接]
2428|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
xiaokai588|  楼主 | 2008-4-27 10:49 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
初学STM32,用的是101VB,使用ADC时不知道“音序器级别”是何意思,我想依次转换6个通道,如何配置?谢了!
沙发
xiaokai588|  楼主 | 2008-4-28 09:32 | 只看该作者

请高手多多指教

请高手多多指教

使用特权

评论回复
板凳
walnutcy| | 2008-4-28 09:54 | 只看该作者

你试下这个函数:

  ADC_RegularChannelConfig(ADC1, ADC_Channel_14, 1, ADC_SampleTime_55Cycles5);


没有板子,我没法试多通道,
单通道的例程如下:
void ADCInit(void)
{
   /* ADC1 configuration ------------------------------------------------------*/
  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;
  ADC_Init(ADC1, &ADC_InitStructure);

  /* ADC1 regular channel14 configuration */ 
//在这配置输入管脚与所选的通道,
  ADC_RegularChannelConfig(ADC1, ADC_Channel_14, 1, ADC_SampleTime_55Cycles5);
 
  /* Enable ADC1 */
  ADC_Cmd(ADC1, ENABLE);

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

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

采样:
long TestADValue (int argc, char *argv[])
{
#ifdef USE_USART2_STDEMO
  /* Start ADC1 Software Conversion */ 
  ADC_SoftwareStartConvCmd(ADC1, ENABLE);
    
  if(IS_ADC_GET_FLAG(ADC_FLAG_EOC))
  {
      printf(" CurrentValue: 0x%04X ",ADC_GetConversionValue(ADC1));
  }
#else
  printf(" No AD connect! ");
#endif
  
  return 0;
}

还要注意配置管脚模式:
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1 | RCC_APB2Periph_GPIOC, ENABLE);
  /* Configure PC.04 (ADC Channel14) as analog input -------------------------*/
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
  GPIO_Init(GPIOC, &GPIO_InitStructure);


你试着改采样函数即可,
在采样中调用函数改通道,

使用特权

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

本版积分规则

1

主题

5

帖子

1

粉丝