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

📄 multint.c

📁 ADuC7020/26是ADI模拟公司开发的ARM7TDMI内核
💻 C
字号:
/*********************************************************************

 Author        : ADI - Apps            www.analog.com/MicroConverter

 Date          : Feb. 2004

 File          : MultInt.c

 Hardware      : ADuC7026

 Description   : Example program using two IRQs and 1 FIQ.
 				 Timer1 causes an IRQ which compliments P4.2.
 				 XIRQ0 causes an IRQ which compliments P4.2.
 				 ADC causes an FIQ which outputs the value on ADC0 
				 to DAC1.
		
*********************************************************************/

#include <ADuC7026.h>						// 	Include ADuC7026 Header File
											
//	Function Prototypes

void IRQ_Handler(void) __irq;				//	IRQ Function Prototype 
void FIQ_Handler(void) __fiq;				// 	FIQ Function Prototype
void ADCpoweron(int);
void delay(int);

 void DemoConfig(void);
 long ADCconvert(void);
 void My_IRQ_Function(void);

// MAIN PROGRAM....

int main (void)  {

	DemoConfig();						// set up ADC, DAC, & reference


	GP0CON = 0x00100000;				// Enable ADCbusy on Pin 0.5
	GP4DAT = 0x04000000;				//	Configure P4.2 as output
	GP3DAT = 0xff000000;				//	Configure port 3 as output
										// Timer 1 configuration
	T1LD = 0x20000;						// Counter Value
	T1CON = 0xC4;						// Enabled,Periodic,Binary and CLK/16

	IRQEN = XIRQ0_BIT+GP_TIMER_BIT;		//	Enable XIRQ0 and Timer1 IRQ
	FIQEN = ADC_BIT;					//	Enable ADC FIQ

	while(1)
	{
		GP3DAT ^= 0x00ff0000;			// Compliment P3 
		ADCCON = 0x4E3;					// single conversion, ADC Speed = 1 MSPS
		delay(0x2000);					// Delay Blinking of P3
	}
	
	return 0 ;
}

void delay (int length)
{
while (length >=0)
    length--;
}

void DemoConfig(void) {				// ADC, DAC and Reference configuration
	ADCpoweron(20000);				// power on ADC
	ADCCP = 0x00;					// conversion on ADC0
	DAC1CON = 0x13;					// AGND-AVDD range
	REFCON = 0x01;					// internal 2.5V reference
	return;
}

void ADCpoweron(int time)
{
	ADCCON = 0x20;	 					// power-on the ADC
	while (time >=0)	  				// wait for ADC to be fully powered on
    time--;
}


/********************************************************************/
/*                                                                  */
/*		Interrupt Service Rountine									*/
/*                                                                  */
/********************************************************************/


void IRQ_Handler() __irq						// example with two IRQ
{				
	if ((IRQSTA & GP_TIMER_BIT) != 0)	 		// Timer1 IRQ?
	{
		T1CLRI = 0;								// Clear Timer IRQ
		GP4DAT ^= 0x00040000;					// Complement P4.2
	} 				
	if ((IRQSTA & XIRQ0_BIT) != 0) 				// external IRQ?
	{	
		GP4DAT ^= 0x00040000;					// Complement P4.2
		while(GP0DAT & 0x00010){}				// wait for XIRQ to be low again
	}			 
	return ;
} 

void FIQ_Handler() __fiq						// example with one FIQ			
{							
	if ((FIQSTA & ADC_BIT) != 0) 				// ADC FIQ ?
	{	
		DAC1DAT = ADCDAT;						// Output ADC0 Value onto DAC1
	}											// required to clear ADC interrupt
	return ;
}

⌨️ 快捷键说明

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