基于MSP430F149的应用实例
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>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);
}
}
//P5DIR=0xFF;
//#######################################################################
P5OUT |= START; //=1 停止计数,读取12位计数器的数据
P5OUT &= ~A1; //=0
P5OUT &= ~A0; //=0
bDat0_L =P4IN; //先读取低8位
P5OUT &= ~A1; //=0
P5OUT |= A0; //=1
bDat0_H =P4IN; //再读取高4位
bDat0_H &= 0x0F;
P5OUT |= A1; //=1
P5OUT &= ~A0; //=0
bDat1_L =P4IN; //先读取低8位
P5OUT |= A1; //=1
P5OUT |= A0; //=1
bDat1_H =P4IN; //再读取高2位
bDat1_H &= 0x03;
P5OUT |= START; //=1 停止计数,读取12位计数器的数据
//P5OUT &=~RES; //=0
//DisInt(1,bDat0_L);
//DisInt(2,bDat0_H);
//gb_Flag&=~BIT_7; //计数时(16秒定时),显示滚动条时用
//DisProcessBar(); //显示滚动条,占16秒时间
wDat0 =(Counter1*4096+bDat0_H *256 + bDat0_L)/16; //组合成一个16位数
wDat1 =(Counter2*1024+bDat1_H *256 + bDat1_L)/16; //组合成一个16位数bDat1_L;//
MeasureData=wDat0-wDat1;
MeasureData=6532267;
}
/*主程序*/
void main(void)
{
unsigned char key,iic_value,LanguageFlag,kj;
unsigned int pi;
//WDTCTL = WDTPW + WDTHOLD; // 停止WDT
InitMcu430();
P1DIR=0x06; //p1.1,p1.2--OUT
P2DIR=0xFF;
P3DIR|=0x0F;
P4DIR=0x00;
P5DIR=0xFF;
kj=0;
InitHd44780();//初始化液晶
CGRAM(); //建立自定义字符库
Uart0Init(); //初始化串口0
SendData(); //发送 0x50 0x51
LanguageFlag=0x11;
RW24XX(&LanguageFlag,1,0x0007,0xA0);
RW24XX(&kj,1,0x0007,0xA1);
DisCharzz(LanguageFlag); //kj=23;
DisChar(kj);
//write_eeprom(0xa0,0x02,0x20);
//iic_value = read_eeprom(0xa0,0x02);
//DisChar(iic_value);
// IIC_Send(0x20);
// iic_value=IIC_Recive();
// DisChar(iic_value);
ReadyMeaFlag=0;
gb_Flag|=BIT_7; //启动时,显示倒计时用
gb_Flag|=BIT_0;
gb_Flag&=~BIT_6;
gb_Flag&=~BIT_5;
gb_Flag&=~BIT_4;
//DisStartScr();
//DisChar(iic_value);
//Ready(); //倒计时16秒
gb_Flag&=~BIT_7; //计数时(16秒定时),显示滚动条时用
//DisProcessBar(); //显示滚动条
//Dis_Ready(); //待机时,显示 "ready"
while(1){
key =P1IN;
key &=BIT_0;
for(pi=0;pi<25000;pi++)
key =P1IN;
key &=BIT_0;
if(key!=BIT_0) ReadyMeaFlag=1; //低电平,表示抽屉拉开,准备测量
if((key==BIT_0)&&(ReadyMeaFlag==1)) //高电平,表示抽屉合上,开始测量
{
WriteCom(0x01); //Clr Screen
ReadData();
DisLongInt(); //显示测量数据
gb_Timer1s=0;
gb_Flag|=BIT_6; //开始延时,等待几秒后清除显示数据,显示"Ready"
ReadyMeaFlag=0;
}
if((gb_Flag&BIT_5)==BIT_5)
{
WriteCom(0x01); //Clr Screen
Dis_Ready();
gb_Flag&=~BIT_5;
}
}
}
MSP430F149应用实 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)