test44x_adc12_01.c

来自「MSP430F449的AD转换的相关VC程序」· C语言 代码 · 共 32 行

C
32
字号


#include          "msp430x44x.h" // Standard Equations

static unsigned int results[2];         // Needs to be global in this example
                                        // Otherwise, the compiler removes it
                                        // because it is not used for anything.

void main(void)
{ 
  WDTCTL = WDTPW+WDTHOLD;               // Stop watchdog timer
  ADC12CTL0 = ADC12ON+MSC+SHT0_15;      // Turn on ADC12, set sampling time
  ADC12CTL1 = SHP+CONSEQ_1;             // Use sampling timer, single sequence
  ADC12MCTL0 = INCH_8;                  // ref+=AVcc, channel = A8
  ADC12MCTL1 = INCH_9+EOS;              // ref+=AVcc, channel = A9, end seq.
  ADC12IE = 0x02;                       // Enable ADC12IFG.1
  ADC12CTL0 |= ENC;                     // Enable conversions
  _EINT();                              // Enable interrupts  

  while(1)
  {
  ADC12CTL0 |= ADC12SC;                 // Start conversion
  _BIS_SR(LPM0_bits);                   // Enter LPM0 
   }
}

interrupt[ADC_VECTOR] void ADC12ISR (void)
{
  results[0] = ADC12MEM0;               // Move results, IFG is cleared
  results[1] = ADC12MEM1;               // Move results, IFG is cleared  
  _BIC_SR_IRQ(LPM0_bits);               // Clear LPM0, SET BREAKPOINT HERE
}

⌨️ 快捷键说明

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