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

📄 8bit_adc_interrupt.c

📁 范例程序 SONiX
💻 C
字号:
#include <sn8p2758.h>
#include "adc_8bit.h"

unsigned int adc_buf;

void main (void)
{
	FADENB=1;						// Enable ADC circuit
	delay(100);						// Delay 100us
	P4UR=0xfe;						// Disable P4.0 pull-up resistor
	P4M=0x00;						// Set P40 as input pin
	P4CON=0x01;						// Set P40 as pure analog input
	ADR=0x40;						// To set 8-bit and  Fcpu/1.		
	ADM=0x90;						// Enable ADC and set AIN0 input
	FADCIEN=1;						// Enable ADC interrupt service
	FADCIRQ=0;						// Clear ADC interrupt request flag
	FGIE=1;							// Enable GIE
	FADS=1;							// To start conversion

//===============================================
// 
//		User code  		
//	
//===============================================    


}

void delay (unsigned int i)
{
	unsigned int  j;
	for (j=i;j>0;j--)
	NOP(1);
}

__interrupt isr(void)
{
	if((FADCIEN==1)&&(FADCIRQ==1))
	{
		FADCIRQ=0;
		adc_buf=ADB;					// To get AIN0 input data adc_isr=1;
	}	
}	 

⌨️ 快捷键说明

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