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

📄 sys_isr.c

📁 中颖单片机的基础驱动程序源代码ADC
💻 C
字号:
#include	".\head\intrins.h"	
#include	".\head\CPU161.h"
#include	".\head\define.h"
#include	".\head\global.h"


/****************************************************************************
 * Function Description:the interrupt entrance : INT0
 * Input parameter     :void
 * Output paramter     :void
 ****************************************************************************/
void	INT0_ISP(void) interrupt 0
{
	EA	= 0;		
	IE0 = 0;								
	//-------------------
	//-------------------
	EA	=	1;	
}
/****************************************************************************
 * Function Description:the interrupt entrance : Timer0
 * Input parameter     :void
 * Output paramter     :void
 ****************************************************************************/
void	Timer0_ISP(void) interrupt 1
{
	EA	=	0;		
	TF0  = 0;							
	//-------------------
	//-------------------
	EA	=	1;
}
/****************************************************************************
 * Function Description:the interrupt entrance : INT1
 * Input parameter     :void
 * Output paramter     :void
 ****************************************************************************/
void	INT1_ISP(void) interrupt 2
{
	EA	=	0;
	IE1 =   0;
	//-------------------
	//-------------------
	EA	=	1;
}

/****************************************************************************
 * Function Description:the interrupt entrance : Timer1
 * Input parameter     :void
 * Output paramter     :void
 ****************************************************************************/
void	Timer1_ISP(void) interrupt 3
{
	EA	 = 0;
	TF1  = 0;							
	//-------------------
	//-------------------
	EA	=	1;
}

/****************************************************************************
 * Function Description:the interrupt entrance : EUART
 * Input parameter     :void
 * Output paramter     :void
 ****************************************************************************/
void	EUART_ISP(void) interrupt 4
{
	EA	=	0;
	EA	=	1;
}

/*************************************************************************************************
 * Function Description:the interrupt entrance : Timer2
 * Input parameter     :void
 * Output paramter     :void
 *************************************************************************************************/
void	Timer2_ISP(void) interrupt 5
{
	EA	=	0;	
	TF2 =   0;
	EXF2=   0;	
	//-------------------
	//-------------------
	EA	=	1;	
}

/*************************************************************************************************
 * Function Description:the interrupt entrance : ADC
 * Input parameter     :void
 * Output paramter     :void
 *************************************************************************************************/
void	ADC_ISP(void) interrupt 6
{
	static bit	bdata	pbADFirstTime;
	static Word data 	pWADCBuf;
	static Byte data 	pBADCSampleTime;
	static Byte data 	pBADValue_T1_Buf;
	static Byte data 	pBADValue_T2_Buf;

	Byte data channel;
	Byte data value;

	EA	=	0;		
	ADCON &= Bin(10111111);									//clear ADCIF
	//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/	
	pWADCBuf +=ADDH;										//accumulate 256 times
	if((++pBADCSampleTime)==0x00)							
	{										
		value	= HIBYTE(pWADCBuf);							//get average value of 256 times
		pWADCBuf = 0x0000;									//clear accumulate buffer
		channel = (ADCON & Bin(00001110))>>1;				//get current channel
		switch(channel)
		{
			//I value---------------------------------------------------------------------------
			case 0:					
				gBADValue_I = value;						//save I without debounce
				channel ++;									//next channel
				break;
			//T1 value--------------------------------------------------------------------------
			case 1:								
				if(pbADFirstTime)
				{	//not first time		
					if(pBADValue_T1_Buf == value)			//equal with last time ?
					{
						gBADValue_T1 = value;				//save T1 for it's stable
						gBT1 = TAB_TEMP[value];
						if(	(gBADValue_T1<3) || (gBADValue_T1>252))	
						{
							gbE5 = 1;						//T1 sensor error
						}
						else
						{
							gbE5 = 0;						//T1 sensor no error
						}
					}
				}
				pBADValue_T1_Buf = value;					//value to the T1 buffer
				channel ++;									//next channel
				break;
			//T2 value--------------------------------------------------------------------------
			default:							
				if(pbADFirstTime)
				{	//not first time
					if(pBADValue_T2_Buf == value)			//equal with last time ?
					{	
						gBADValue_T2 = value;				//save it for it's stable
						gBT2 = TAB_TEMP[value];
						if(	(gBADValue_T2<3) || (gBADValue_T2>252))	
						{
							gbE6 = 1;						//T2 sensor error
						}
						else
						{
							gbE6 = 0;						//T2 sensor no error
						}	
					}
				}
				pBADValue_T2_Buf = value;
				pbADFirstTime = 1;							//end all channel after Power On
				channel = 0;								//next channel
				break;
		}
		ADCON &= Bin(11110001);								//set channel
		ADCON |= (channel<<1);
	}	
	ADCON |= Bin(00000001);									//ADC restart	
	//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/		
	EA	=	1;	
}


/****************************************************************************
 * Function Description:the interrupt entrance : SPI
 * Input parameter     :void
 * Output paramter     :void
 ****************************************************************************/
void	SPI_ISP(void) interrupt 7
{
	EA	=	0;					
	EA	=	1;	
}

/****************************************************************************
 * Function Description:the interrupt entrance : INT2
 * Input parameter     :void
 * Output paramter     :void
 ****************************************************************************/
void	INT2_ISP(void) interrupt 8
{
	EA	=	0;	
	IE2 =   0;
	//-------------------
	//-------------------;
	EA	=	1;	
}


/****************************************************************************
 * Function Description:the interrupt entrance : INT3
 * Input parameter     :void
 * Output paramter     :void
 ****************************************************************************/
void	INT3_ISP(void) interrupt 9
{
	EA	=	0;		
	IE3 =   0;			
	//-------------------
	//-------------------	
	EA	=	1;	
}




/****************************************************************************
 * Function Description:the interrupt entrance : INT4
 * Input parameter     :void
 * Output paramter     :void
 ****************************************************************************/
void	INT4_ISP(void) interrupt 10
{
	EA	=	0;		
	EA	=	1;	
}


/****************************************************************************
 * Function Description:the interrupt entrance : PWM
 * Input parameter     :void
 * Output paramter     :void
 ****************************************************************************/
void	PWM_ISP(void) interrupt 12
{
	EA	=	0;					
	EA	=	1;	
}

/****************************************************************************
 * Function Description:the interrupt entrance : OVLNMI
 * Input parameter     :void
 * Output paramter     :void
 ****************************************************************************/
void	OVLNMI_ISP(void) interrupt 15
{
	EA	=	0;
	EA	=	1;
}

⌨️ 快捷键说明

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