adc.c

来自「STMicroelectronics STR7xFxx A/D Example 」· C语言 代码 · 共 27 行

C
27
字号
#include <71x_lib.H>
#include <stdio.h>
#define VREF 2.5

u16 data;
void main(void){


GPIO_Config(GPIO1, 0x0001, GPIO_HI_AIN_TRI);      // P1.0: Analog Input
ADC12_Init();	                                  // Initialize the converter registers
ADC12_PrescalerConfig(500);		                  // configure the prescaler
ADC12_ModeConfig(ADC12_SINGLE);	                  // Enable Single mode of conversion
ADC12_ChannelSelect(ADC12_CHANNEL0);              //select the channel 0 to be converted


while (1){

					  
 ADC12_ConversionStart();						  //Start the conversion
 while (!ADC12_FlagStatus (ADC12_DA0));			  //Wait for conversion
  if (ADC12_FlagStatus(ADC12_OR) == RESET)		  //Test the overrun bit

  data = ADC12_ConversionValue(ADC12_CHANNEL0);	   //Get the conversion result


}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?