为什么我的这个程序实现不了数码管显示啊。。各位大侠帮帮忙啊。。本人菜鸟一枚啊,程序附上:
#include <MSP430x24x.h>
#define uchar unsigned char
#define uint unsigned int
#define LCK_SET P1OUT|=1
#define LCK_CLR P1OUT&=~1
uchar const table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07, //共阴数码管段选码表,无小数点
0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
unsigned int Data;
volatile unsigned int i;
void delayms(uint t)
{
uint i;
while(t--)
for(i=1330;i>0;i--);//进过参数的调整
}
void SendSpi(uchar Dat)
{
UCA0TXBUF = Dat;
while (!(IFG2 & UCA0TXIFG));
// return(UCA0TXBUF);
}
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P3SEL |= 0x11; // P3.0,4 USCI_A0 option select
UCA0CTL0 |= UCCKPH + UCMSB + UCMST + UCSYNC; // 3-pin, 8-bit SPI master
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 |= 0x02;
UCA0BR1 = 0;
UCA0MCTL = 0;
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
P1DIR=0x01;
P1SEL=0;
Data = 0x0FF; // Load inital data
while(1);
{
Data++; // Increment Data value - Set BREAKPOINT here
SendSpi(table[Data%16]);
LCK_CLR;
LCK_SET;
delayms(100); // Delay
}
} |