马上注册,结交更多好友,享用更多功能,让你轻松玩转社区
您需要 登录 才可以下载或查看,没有账号?立即注册
×
#include "msp430x14x.h"
#define LT0 P3OUT&=~BIT0
#define LT1 P3OUT|=BIT0
#define SK0 P3OUT&=~BIT1
#define SK1 P3OUT|=BIT1
#define EN0 P3OUT&=~BIT2
#define EN1 P3OUT|=BIT2
#define R0 P3OUT&=~BIT3
#define R1 P3OUT|=BIT3
#define LS P1OUT
const char Table[]={
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x3F,0xF0,0xCF,0xE7,0xE7,0xCF,0xF3,0x9F,0xF3,0x9F,
0xF3,0x9F,0xF3,0x9F,0xF3,0x9F,0xE7,0xCF,0xCF,0xE7,0x3F,0xF8,0xFF,0xFF,0xFF,0xFF,/*"0",0*/
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0x07,0xFE,0x7F,0xFE,0x7F,0xFE,0x7F,0xFE,
0x7F,0xFE,0x7F,0xFE,0x7F,0xFE,0x7F,0xFE,0x7F,0xFE,0x07,0xE0,0xFF,0xFF,0xFF,0xFF,/*"1",1*/
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x1F,0xF0,0xE7,0xC7,0xFB,0xCF,0xF3,0xCF,0xFF,0xE7,
0xFF,0xFB,0xFF,0xFC,0x3F,0xFF,0xCF,0xDF,0xF7,0xCF,0x03,0xE0,0xFF,0xFF,0xFF,0xFF,/*"2",2*/
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x0F,0xF8,0xF3,0xE3,0xF3,0xE7,0xFF,0xF3,0x3F,0xFC,
0xFF,0xE3,0xFF,0xCF,0xFF,0xCF,0xF3,0xCF,0xF3,0xE3,0x0F,0xF8,0xFF,0xFF,0xFF,0xFF,/*"3",3*/
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF3,0xFF,0xF0,0x7F,0xF1,0xBF,0xF1,0xDF,0xF1,
0xE7,0xF1,0xFB,0xF1,0x01,0x80,0xFF,0xF1,0xFF,0xF1,0x3F,0x80,0xFF,0xFF,0xFF,0xFF,/*"4",4*/
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x0F,0xC0,0xEF,0xFF,0xEF,0xFF,0xF7,0xFF,0x17,0xF0,
0xE7,0xE7,0xFF,0xCF,0xFF,0xCF,0xF3,0xCF,0xFB,0xE3,0x07,0xF8,0xFF,0xFF,0xFF,0xFF,/*"5",5*/
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x3F,0xE0,0x8F,0xCF,0xE7,0xFF,0xF7,0xFF,0x33,0xE0,
0xC3,0xCF,0xF3,0x9F,0xF3,0x9F,0xE7,0x9F,0xCF,0xCF,0x1F,0xF0,0xFF,0xFF,0xFF,0xFF,/*"6",6*/
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x07,0xC0,0xF3,0xEF,0xFB,0xF7,0xFF,0xFB,0xFF,0xFD,
0xFF,0xFE,0x7F,0xFF,0x7F,0xFF,0x3F,0xFF,0x3F,0xFF,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,/*"7",7*/
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x0F,0xF0,0xE3,0xC7,0xF3,0xCF,0xE3,0xCF,0x8F,0xF7,
0x4F,0xF8,0xF3,0xE3,0xF9,0xCF,0xF9,0xCF,0xF3,0xE7,0x0F,0xF8,0xFF,0xFF,0xFF,0xFF,/*"8",8*/
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x0F,0xF8,0xF3,0xE3,0xF9,0xEF,0xF9,0xCF,0xF9,0xCF,
0xF3,0xC3,0x07,0xCC,0xFF,0xE7,0xFF,0xE7,0xF3,0xF1,0x07,0xFC,0xFF,0xFF,0xFF,0xFF,/*"9",9*/
};
void delay(unsigned int n) //延时函数
{ unsigned int k;
for(k=0;k<n;k++);
}
void IO_Init(void)
{
//IO初始化---------------------------------------
P1DIR |=0xFF;
P3DIR |=0xFF;
}
void SendDate(unsigned char Data)
{
unsigned char i;
for(i = 0; i < 8; i++)
{
if(Data&0x01) R1; //串行输出Data数据
else R0;
SK0;
Data=Data>>1;
//_NOP();
SK1;
}
}
void led_show1(int i,int j,int k,int l)//静态显示16X16汉字
{
unsigned int num;
for(num=0;num<16;num++)
{
SendDate(Table[num*2+0+32*i]);
SendDate(Table[num*2+1+32*i]);
SendDate(Table[num*2+0+32*j]);
SendDate(Table[num*2+1+32*j]);
SendDate(Table[num*2+0+32*k]);
SendDate(Table[num*2+1+32*k]);
SendDate(Table[num*2+0+32*l]);
SendDate(Table[num*2+1+32*l]);
EN1; //关显示屏片选
delay(500);
//_NOP();//消影
LT1;
LT0; //输出锁存
LS=num; //16行地址
//_NOP();//消影
EN0; //开显示屏片选
}
}
void main( void )
{
char z;
WDTCTL = WDTPW + WDTHOLD;
IO_Init();
/*------选择系统主时钟为8MHz-------*/
BCSCTL1 &= ~XT2OFF; //打开XT2高频晶体振荡器
do
{
IFG1 &= ~OFIFG; //清除晶振失败标志
for (z = 0xFF; z > 0; z--); //等待8MHz晶体起振
}
while ((IFG1 & OFIFG)); //晶振失效标志仍然存在?
BCSCTL2 |= SELM_2 + SELS; //MCLK和SMCLK选择高频晶振
while(1)
{
unsigned int i,j,k,l;
i=5;j=6;k=7;l=9;
led_show1(i,j,k,l);
}
} |