最近在学430,但是总遇到这样那样的问题,还请各位多多指点啊~~#include "msp430x21x2.h" void Delay(unsigned short time);unsigned int ad_value[3]; void main(){ WDTCTL = WDTPW + WDTHOLD; // Stop WDT ADC10CTL0 = SREF_1+REFON+REF2_5V+ADC10SHT_2 + MSC+ADC10ON+ADC10IE; // ADC10ON, interrupt enabled ADC10CTL1 = INCH_2+CONSEQ_1; ADC10DTC1 = 0x03; // 3 conversions ADC10AE0 |= 0x07; // P2.2,1,0 ADC10 option select P1DIR =0X01; Delay(1); while(1) { //P1OUT |=0X01; ADC10CTL0 &= ~ENC; while (ADC10CTL1 & BUSY); // Wait if ADC10 core is active ADC10SA = (unsigned int)ad_value+1; // Data buffer start ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start __bis_SR_register(CPUOFF + GIE); // LPM0, ADC10_ISR will force exit if(ad_value[0]>0) P1OUT |=0X01; } }
#pragma vector=ADC10_VECTOR __interrupt void ADC10(void) { _BIC_SR(CPUOFF); // Clear CPUOFF bit from 0(SR) }
void Delay(unsigned short time){ unsigned short i, j; for(; time > 0; time--) { for(j = 0; j < 10; j++) { for(i = 0; i < 100; i++); } }}
这是自已弄的一小段程序,想用数组把转换的数据读出来,数组的首地址送给ADC10SA,不知这样可对
ADC10SA = (unsigned int)ad_value+1;现在就是数组里面读不出东西,请各位帮着分析下,哪里出了问题的~~~
[
本帖最后由 woody13 于 2012-3-10 16:05 编辑 ]
此帖出自
小平头技术问答
一周热门 更多>