//=================msp430f5438a ADC_13,单通道重复测量
//#include
#include
#define Num_of_Results 8
unsigned int results[Num_of_Results];
unsigned int index=0;
void ADC_13_Config(void);
void main(void)
{
WDTCTL=WDTPW+WDTHOLD;
ADC_13_Config( );
while(1)
{
while(!ADC12IFG13);
results[0]=ADC12MEM0;
}
}
void ADC_13_Config(void)
{
P7SEL=0x20; //P7.5 A13端口输入 //P7.5 开启ADC功能
//REFCTL0|=REFMSTR+REFVSEL_2+REFON; //开启参考电压
ADC12CTL0&=~ADC12ENC;
ADC12CTL0=ADC12SHT0_15+ADC12SHT1_15+ADC12REF2_5V+ADC12REFON+ADC12ON;
ADC12CTL1=ADC12SHP+ADC12CONSEQ_2; //单通道重复采样
ADC12CTL2|=ADC12TCOFF;
ADC12MCTL0=ADC12SREF_0+ADC12INCH_13; //参考电压选择源电压
_NOP();
_NOP();
_NOP();
ADC12CTL0|=ADC12ENC;
ADC12CTL0=ADC12SC; //开始采样
ADC12IE=BITD ;
_BIS_SR(GIE);
}
#pragma vector=ADC12_VECTOR
__interrupt void ADC12ISR(void)
{
results[index]=ADC12MEM0; //保存结果
index=(index+1)%Num_of_Results;
if((Num_of_Results-1)==index)
_NOP();
}
这是我写的msp430f5438a的adc采集程序,寄存器都配置好了,但是在编译时在watch中看memo中的数据始终看不到,只显示00;