我想调G2板子上的ADC10,写了这个程序,从P1.1输入,当输出超过一定值P1.0灯灭、
#include "msp430g2231.h"
void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT ADC10CTL0 = SREF_0+ADC10SHT_2 + ADC10ON + ADC10IE+REFON; // ADC10ON, interrupt enabled ADC10CTL1=INCH_1+CONSEQ_0; ADC10AE0 |= BIT1 ; // P2.0 ADC option select P1DIR |= BIT0; // Set P1.0 to output direction
while(1) { ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start __bis_SR_register(CPUOFF + GIE); // LPM0, ADC10_ISR will force exit if (ADC10MEM < 0x1FF) P1OUT |= BIT0; // Clear P1.0 LED off else P1OUT &= ~BIT0; // Set P1.0 LED on } }
// ADC10 interrupt service routine #pragma vector=ADC10_VECTOR __interrupt void ADC10_ISR(void) { __bic_SR_register_on_exit(CPUOFF); // Clear CPUOFF bit from 0(SR) }
大家帮忙看下,或者你有你试验成功的上传一份哈。简单的就好。。谢谢
[
本帖最后由 shaq 于 2011-11-1 09:16 编辑 ]
此帖出自
小平头技术问答
一周热门 更多>