#include <msp430x14x.h>
#define uint unsigned int
#define uchar unsigned char
//P1.2接RD(第9脚)
#define MOD1_1 P1OUT |= BIT0 //P1.0接MOD1(第14脚)
#define MOD1_0 P1OUT &= ~BIT0
#define MOD2_1 P1OUT |= BIT1 //P1.1接MOD2(第15脚)
#define MOD2_0 P1OUT %= ~BIT1
void SysInit(uint x)
{
if (x == 1)
{
P1DIR = 0XFF;P1OUT = 0XFF; //初始化P1
P2DIR = 0XFF;P2OUT = 0XFF; //初始化P2
P3DIR = 0XFF;P3OUT = 0XFF; //初始化P3
P4DIR = 0XFF;P4OUT = 0XFF; //初始化P4
P5DIR = 0XFF;P5OUT = 0XFF; //初始化P5
P6DIR = 0XFF;P6OUT = 0XFF; //初始化P6
WDTCTL = WDTPW + WDTHOLD; //封闭看门狗
}
}
int main( void )
{
SysInit(1);
MOD2_0; //运用形式1,即解调形式
MOD1_1;
P3DIR = 0x00; //设置P1.2为输入状况
P4OUT = P3IN & BIT2;
while (1)
{
P4OUT = P3IN & BIT2;
if(P4OUT == 0) //AI输入为2100Hz
{
P2OUT &= ~BIT0;
}
else
{
P2OUT &= ~BIT1;
}
}
}