⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 adc.c

📁 STMicroelectronics STR7xFxx A/D Example Program
💻 C
字号:
#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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -