这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 综合技术 » 基础知识 » adc10,f1232 求测试程序,adc10 , f1232

共2条 1/1 1 跳转至

adc10,f1232 求测试程序,adc10 , f1232

院士
2006-09-17 18:14:16     打赏
adc10,f1232 求测试程序,adc10 , f1232



关键词: adc10     f1232     测试     程序    

院士
2006-12-22 22:43:00     打赏
2楼
问 需要测量A2, 单通道单次测量即可,谢谢 1: #include <MSP430x12x2.h>

void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
ADC10CTL1 = INCH_2 + CONSEQ_1; // A2/A1/A0, single sequence
ADC10CTL0 = ADC10SHT_2 + MSC + ADC10ON + ADC10IE;
ADC10DTC1 = 0x03; // 3 conversions
ADC10AE |= 0x07; // P2.2,1,0 ADC10 option select
P1DIR |= 0x01; // Set P1.0 output

for (;;)
{
ADC10CTL0 &= ~ENC;
while ((ADC10CTL1 & BUSY)); // Wait if ADC10 core is active
ADC10SA = 0x200; // Data buffer start
P1OUT |= 0x01; // P1.0 = 1
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
_BIS_SR(CPUOFF + GIE); // LPM0, ADC10_ISR will force exit
P1OUT &= ~0x01; // P1.0 = 0
}
}

// ADC10 interrupt service routine
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR (void)
{
_BIC_SR_IRQ(CPUOFF); // Clear CPUOFF bit from 0(SR)
}

共2条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]