MSP430單片機(jī)驅(qū)動(dòng)MSM7512程序
#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; //關(guān)閉看門狗
}
}
int main( void )
{
SysInit(1);
MOD2_0; //使用模式1,即解調(diào)模式
MOD1_1;
P3DIR = 0x00; //設(shè)置P1.2為輸入狀態(tài)
P4OUT = P3IN & BIT2;
while (1)
{
P4OUT = P3IN & BIT2;
if(P4OUT == 0) //AI輸入為2100Hz
{
P2OUT &= ~BIT0;
}
else
{
P2OUT &= ~BIT1;
}
}
}
評(píng)論