基于MSP430F149的应用实例
void DisInt(unsigned char num,unsigned int Dn)
{
unsigned char s2[5];
unsigned int temp;
//set CGRAM address(0x80-0x8F :First line, 0xc0-0xCF :Second line)
if(num<2) WriteCom(0x80);
else WriteCom(0xc0);
WriteDat(0x30+num); //"1:" or "2:"
WriteDat(0x3A);
s2[0]=Dn/10000; WriteDat(0x30+s2[0]);//if(s2[0]!=0) WriteDat(0x30+s2[0]); else WriteDat(0x20);
temp=Dn%10000;
s2[1]=temp/1000; WriteDat(0x30+s2[1]);//if(s2[1]!=0) WriteDat(0x30+s2[1]); else WriteDat(0x20);
temp=temp%1000;
s2[2]=temp/100; WriteDat(0x30+s2[2]);//if(s2[2]!=0) WriteDat(0x30+s2[2]); else WriteDat(0x20);
temp =temp%100;
s2[3]=temp/10; WriteDat(0x30+s2[3]);
s2[4]=temp%10; WriteDat(0x30+s2[4]);
}
void DisLongInt(void)
{
char s2[15],i;
i=0;
WriteCom(0x80);
WriteDat(0x52); //显示"Result:"
WriteDat(0x65);
WriteDat(0x73);
WriteDat(0x75);
WriteDat(0x6c);
WriteDat(0x74);
WriteDat(0x3a);
WriteCom(0xc0);
//WriteDat(0x30+num); //"1:" or "2:"
//WriteDat(0x3A);
sprintf(s2,"%lu",MeasureData); //Y_1210
while(s2[i]!=\0) { WriteDat(s2[i]); i++; }
}
/*
void DisIntNum(unsigned char num,unsigned int Dn)
{
unsigned char s2[5];
unsigned int temp;
//set CGRAM address(0x80-0x8F :First line, 0xc0-0xCF :Second line)
WriteCom(0x80+(num-1)*9);
WriteDat(0x30+num); //"1:" or "2:"
WriteDat(0x3A);
s2[0]=Dn/10000; WriteDat(0x30+s2[0]);//if(s2[0]!=0) WriteDat(0x30+s2[0]); else WriteDat(0x20);
temp=Dn%10000;
s2[1]=temp/1000; WriteDat(0x30+s2[1]);//if(s2[1]!=0) WriteDat(0x30+s2[1]); else WriteDat(0x20);
temp=temp%1000;
s2[2]=temp/100; WriteDat(0x30+s2[2]);//if(s2[2]!=0) WriteDat(0x30+s2[2]); else WriteDat(0x20);
temp =temp%100;
s2[3]=temp/10; WriteDat(0x30+s2[3]);
s2[4]=temp%10; WriteDat(0x30+s2[4]);
}*/
void DisStartScr(void)
{
unsigned char zj;
zj=3;
WriteCom(0x84); //set CGRAM address
WriteDat(0x42); //display "BHP9505" B
WriteDat(0x48); //H
WriteDat(0x50); //P
WriteDat(0x39); //9
//WriteCom(0xc0); //set CGRAM address
WriteDat(0x35); //5
WriteDat(0x30); //0
WriteDat(0x35); //5
//zj=0;
while(zj>0) //延时3秒
{
if((gb_Flag&BIT_0)==BIT_0) //用BIT_0来表示一秒定时到
{
zj--;
gb_Flag&=~BIT_0;
}
} //Y_1210
WriteCom(0x01); //Clr Screen
WriteCom(0x81);
WriteDat(0x57); //display "WAIT 09 SECOND"
WriteDat(0x41);
WriteDat(0x49);
WriteDat(0x54);
WriteDat(0x20); //空格
WriteCom(0x89);
WriteDat(0x53);
WriteDat(0x45);
WriteDat(0x43);
WriteDat(0x4f);
WriteDat(0x4e);
WriteDat(0x44);
}
void Dis_Ready(void)
{
//display "ready"
WriteCom(0x85); //set CGRAM address
WriteDat(0x52); //R
//WriteCom(0x87); //set CGRAM address
WriteDat(0x65); //e
//WriteCom(0xC0); //set CGRAM address
WriteDat(0x61); //a
//WriteCom(0xC1); //set CGRAM address
WriteDat(0x64); //d
//WriteCom(0x8a); //set CGRAM address
WriteDat(0x79); //y
}
void Ready(void)
{
unsigned char zi,zj;
zj=11;
zi=9;
while(zj>0)
{
if((gb_Flag&BIT_0)==BIT_0) //用BIT_0来表示一秒定时到
{
DisChar(zi); //display zi on LED
zi--;
zj--;
gb_Flag&=~BIT_0;
}
}
WriteCom(0x01); //Clr Screen
//Dis_Ready();
}
void DisProcessBar(void)
{
unsigned char zs,za,tempFlag;
zs=16;
za=0;
tempFlag=1;
while(zs>0)
{
if((gb_Flag&BIT_1)==BIT_1) //用BIT_1来表示500ms定时到
{
WriteCom(0x80+za); //set CGRAM address
WriteDat(0x06); //滚动条
gb_Flag&=~BIT_1;
za++;
zs--;
//if(tempFlag==1) { if(za>7) { za=0x40; tempFlag=0; } }
}
}
zs=16;
za=0;
tempFlag=1;
while(zs>0)
{
if((gb_Flag&BIT_1)==BIT_1) //用BIT_1来表示500ms定时到
{
WriteCom(0x80+za); //set CGRAM address
WriteDat(0x07); //空白条
gb_Flag&=~BIT_1;
za++;
zs--;
//if(tempFlag==1) {if(za<0x40) { za=0x07; tempFlag=0; } }
}
}
}
void ReadData(void)
{
unsigned char zs,za,temp,tempFlag,key;
unsigned int bDat0_L,bDat0_H,bDat1_L,bDat1_H,j; //,Flag_CO1,Flag_CO2,i
unsigned long int Counter1,Counter2;
Counter1=0;
Counter2=0;
zs=16;
za=0;
tempFlag=1;
StopFlag=0;
//for(j=0;j<50000;j++) //消除按键抖动,准备测量
// for(i=0;i<5;i++);
P4DIR=0x00;
P5DIR=0xCF;
P5OUT |= START; //=1
for(j=0;j<100;j++);
//START、RD信号置为0
P5OUT |=RES; //=1
P5OUT &=~RES; //=0
P5OUT |=RES; //=1
P5OUT |= RD; //=1
P5OUT &= ~RD; //=0 清除标志位CO1,CO2
P5OUT |= RD; //=1
gb_Flag&=~BIT_7; //计数时(16秒定时),显示滚动条时用
P5OUT &= ~START; //=0 开始计数
//##################################################################33
//DisProcessBar(); //显示滚动条,占16秒时间
//P5DIR &=0xCF;
while(zs>0) //显示滚动条,得出进位标志
{
key =P1IN;
key &=BIT_0;
temp=P5IN;
if((temp & CO2)==CO2)
{
Counter2++; //对于wDat0,
P5OUT |= RD; //=1
P5OUT &= ~RD; //=0 清除标志位CO1,CO2
P5OUT |= RD; //=1
}
if((temp & CO1)==CO1)
{
Counter1++;
P5OUT |= RD; //=1
P5OUT &= ~RD; //=0 清除标志位CO1,CO2
P5OUT |= RD; //=1
}
if((gb_Flag&BIT_1)==BIT_1) //用BIT_1来表示500ms定时到
{
WriteCom(0x80+za); //set CGRAM address
WriteDat(0x06); //滚动条
gb_Flag&=~BIT_1;
za++;
zs--;
//if(tempFlag==1) { if(za>7) { za=0x40; tempFlag=0; } }
//DisIntNum(1,Counter1);
//DisIntNum(2,Counter2);
}
key =P1IN;
key &=BIT_0;
if(key!=BIT_0)
//if((key!=BIT_0)&&(keyok ==BIT_0)) //上升沿退出测量
{
WriteCom(0x01); //Clr Screen
WriteCom(0x80); //set CGRAM address
WriteDat(0x4F); //display "OPERATING ERROR"
WriteDat(0x50);
WriteDat(0x45);
WriteDat(0x52);
WriteDat(0x41);
WriteDat(0x54);
WriteDat(0x49);
WriteDat(0x4E);
WriteDat(0x47);
WriteDat(0x20);
WriteDat(0x45);
WriteDat(0x52);
WriteDat(0x52);
WriteDat(0x4F);
WriteDat(0x52);
gb_Timer1s=0;
gb_Flag|=BIT_4;
while(StopFlag==0);
WriteCom(0x01); //Clr Screen
WriteCom(0x80); //set CGRAM address
WriteDat(0x50); //display "PLEASE RESET"
WriteDat(0x4C);
WriteDat(0x45);
WriteDat(0x41);
WriteDat(0x53);
WriteDat(0x45);
WriteDat(0x20);
WriteDat(0x52);
WriteDat(0x45);
WriteDat(0x53);
WriteDat(0x45);
WriteDat(0x54);
//WriteDat(0x52);
while(1);
}
}
zs=16;
za=0x0; //za=0x47;
tempFlag=1;
while(zs>0)
{
key=P1IN;
key &=BIT_0;
temp=P5IN;
if((temp & CO2)==CO2)
{
Counter2++; //对于wDat0,
P5OUT |= RD; //=1
P5OUT &= ~RD; //=0 清除标志位CO1,CO2
P5OUT |= RD; //=1
}
if((temp & CO1)==CO1)
{
Counter1++;
P5OUT |= RD; //=1
P5OUT &= ~RD; //=0 清除标志位CO1,CO2
P5OUT |= RD; //=1
}
MSP430F149应用实 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)