|
前辈们好,我刚接触430,现在遇到了点问题,在下面TI所提供的例子中,中断服务程序里面的“ADC12MEM0 < 0x7FF”怎么就表示A0<0.5Vcc了呢,还有上面因为没有开转换,是不是ADC12MEM0里面存储的是A0里面的值?刚接触,问的问题可能没技术含量,还望前辈们不吝赐教。- //******************************************************************************
- // MSP-FET430P140 Demo - ADC12, Sample A0, Set P1.0 if A0 > 0.5*AVcc
- //
- // Description: A single sample is made on A0 with reference to AVcc.
- // Software sets ADC10SC to start sample and conversion - ADC12SC
- // automatically cleared at EOC. ADC12 internal oscillator times sample (16x)
- // and conversion. In Mainloop MSP430 waits in LPM0 to save power until ADC12
- // conversion complete, ADC12_ISR will force exit from LPM0 in Mainloop on
- // reti. If A0 > 0.5*AVcc, P1.0 set, else reset.
- //
- // MSP430F149
- // -----------------
- // /|\| XIN|-
- // | | |
- // --|RST XOUT|-
- // | |
- // Vin-->|P6.0/A0 P1.0|--> LED
- //
- // M. Buccini
- // Texas Instruments Inc.
- // Feb 2005
- // Built with IAR Embedded Workbench Version: 3.21A
- //******************************************************************************
- #include <msp430x14x.h>
- void main(void)
- {
- WDTCTL = WDTPW + WDTHOLD; // Stop WDT
- ADC12CTL0 = SHT0_2 + ADC12ON; // Set sampling time, turn on ADC12
- ADC12CTL1 = SHP; // Use sampling timer
- ADC12IE = 0x01; // Enable interrupt
- ADC12CTL0 |= ENC; // Conversion enabled
- P6SEL |= 0x01; // P6.0 ADC option select
- P1DIR |= 0x01; // P1.0 output
- for (;;)
- {
- ADC12CTL0 |= ADC12SC; // Sampling open
- _BIS_SR(CPUOFF + GIE); // LPM0, ADC12_ISR will force exit
- }
- }
- // ADC12 interrupt service routine
- #pragma vector=ADC_VECTOR
- __interrupt void ADC12_ISR (void)
- {
- if (ADC12MEM0 < 0x7FF)
- P1OUT &= ~0x01; // Clear P1.0 LED off
- else
- P1OUT |= 0x01; // Set P1.0 LED on
- _BIC_SR_IRQ(CPUOFF); // Clear CPUOFF bit from 0(SR)
- }
复制代码 |
阿莫论坛20周年了!感谢大家的支持与爱护!!
该献的血还是要献的。你不献他不献。难道让我去献? --- 出自坛友:lovejp1981
|