已回答假定已回答

aduc7026 ADC中断

mermaidangel 在 2015-12-9 詢問的問題
最後回覆由mermaidangel於2015-12-16提供

下载官网上adc中断程序到开发板,但dac并没有相应的输出。

 

程序如下:

/*********************************************************************

 

 

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

 

 

Date          : Sept. 2005

 

 

File          : MultInt.c

 

 

Hardware      : Applicable to ADuC702x rev H or I silicon

                 Currently targetting 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 My_IRQ_Function(void); // IRQ Function Prototype

void My_FIQ_Function(void); // FIQ Function Prototype

void ADCpoweron(int);

void delay(int);

 

 

void DemoConfig(void);

long ADCconvert(void);

void My_IRQ_Function(void);

 

 

int main (void)  {

 

 

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

 

 

  IRQ = My_IRQ_Function; // Specify Interrupt Service Rountine

  FIQ = My_FIQ_Function; // Specify Interrupt Service Rountine

 

 

  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 = 0x6E3; // single conversion

  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 My_IRQ_Function() { // 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 My_FIQ_Function() { // example with one FIQ

  if ((FIQSTA & ADC_BIT) != 0) // ADC FIQ ?

  DAC1DAT = ADCDAT; // Output ADC0 Value onto DAC1

  return ;

}

結果