//此程序在MSP430F5529平台上已经调试通过
#include
#define MSB_H P1OUT|=BIT4
#define RS_H P1OUT|=BIT5
#define MSB_L P1OUT&=~BIT4
#define RS_L P1OUT&=~BIT5
#define DAC_A 0x4000
#define DAC_B 0x8000
#define DAC_AB 0xC000
#define SCLK_UP P2OUT|=BIT5
#define SCLK_DOWN P2OUT&=~BIT5
#define CS_UP P2OUT|=BIT4
#define CS_DOWN P2OUT&=~BIT4
#define SDIN_UP P3OUT|=BIT5
#define SDIN_DOWN P3OUT&=~BIT5
#define LDAC_UP P2OUT|=BIT0
#define LDAC_DOWN P2OUT&=~BIT0
/*
* main.c
*/
int main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
P2DIR|=BIT0+BIT4+BIT5;
P3DIR|=BIT5;
P1DIR|=BIT4+BIT5+BIT0;
unsigned short int date;
volatile int i=0;
CS_UP;
LDAC_UP;
RS_H;
MSB_H;
while(1)
{
date=0x0ff+DAC_A;
CS_DOWN;
for(i=0;i<16;i++)
{
SCLK_DOWN;
if(date&0x8000)
SDIN_UP;
else
SDIN_DOWN;
SCLK_UP;
date<<=1;
}
CS_UP;
LDAC_DOWN;
LDAC_UP;
}
}
|