#include <GLOBAL.h>
#include <stdlib.h>
#include <stdbool.h>
#include <msp430x21x2.h>
void ChkInit(void)
{
P2DIR&=0xfe;
P2SEL|=0x01;
ADC10AE0 |= 0x99;
ADC10CTL0 &= ~ENC;
ADC10CTL0 |=ADC10ON+ADC10SHT_3+ADC10IE+REFON+REF2_5V+SREF0;//打开ADC10 内核,设定采样保持时间为64
}
void ChkPick(unsigned int *DataDptr,unsigned int TimesliceFg)
{
unsigned int i;
i=~TimesliceFg;
if(ChkAdFg)
{
ChkAdFg=0;
ChkIntData=ChkData;
// --- 湿度补偿数据提取
ChkVoltage=ChkIntData*76628;
ChkVoltage=ChkVoltage/10000;
}
if(*DataDptr&TimesliceFg)
{
*DataDptr&=i;
ADC10CTL1=INCH_0;
ADC10CTL0 |=ENC+ADC10SC; //启动AD转换
}
}
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR(void)
{
ChkData = ADC10MEM;//将AD 采样值存入ad_value
ADC10CTL0 &= ~ENC;
ChkAdFg=1;
}
|