• 大小: 23KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-03
  • 语言: 其他
  • 标签: LCD1602  MSP430  

资源简介

LCD1602程序 for MSP430F449,本人编写的详细源代码,供学习和工作参考使用。值得下载和收藏。

资源截图

代码片段和文件信息

/*******************************************************************************
*  描述:                                                                       *
*         1602字符型LCD显示演示程序                                            *
*         在第一行显示  welcome                                                *
*         在第二行显示  www.ycit.cn                                         *
*                                                                              *
********************************************************************************/


#ifndef uchar
#define uchar unsigned char
#endif
#ifndef uint 
#define uint unsigned int
#endif
#define nop _NOP()

//RS--P5.6  RW--P5.5  E--P5.4
//sbit RS = P2^6; //
//sbit RW = P2^5;
//sbit E = P2^7;
#define RS_1 P5OUT |= BIT6
#define RS_0 P5OUT &= ~BIT6
#define RW_1 P5OUT |= BIT5
#define RW_0 P5OUT &= ~BIT5  ////
#define E_1  P5OUT |= BIT4
#define E_0  P5OUT &= ~BIT4
uchar  dis1[] = {“welcome!“};
uchar  dis2[] = {“www.ycit.cn“};
/*
void RS(char s)
{
if(s==1) P5OUT |= BIT6;
else  P5OUT &= ~BIT6;
}
void RW(char s)
{
if(s==1) P5OUT |= BIT5;
else  P5OUT &= ~BIT5;
}
void E(char s)
{
if(s==1) P5OUT |= BIT4;
else  P5OUT &= ~BIT4;
}  */
/**********LCD1602.c 函数声明***************/
void delay(uchar ms);      //延时3*ms毫秒
uchar lcd_bz();              //测试LCD忙碌状态
void write_cmd1(uchar cmd1);  //写入指令数据到LCD
void write_cmd(uchar cmd);  //写入指令数据到LCD
void lcd_pos(uchar pos);   //设定显示位置
void write_data(uchar dat); //写入字符显示数据到LCD
void LCD_Init();           //LCD初始化设定

void delay(uchar ms)
{ // 延时子程序
  uchar i;
  while(ms--)
  {
   for(i = 0; i< 250; i++)
   {
nop;
nop;
nop;
nop;
   }
  }
}
void delay_ms(int ms)
{ // 延时子程序
  uchar i;
  while(ms-- >0)
  {
   for(i = 0; i< 250; i++)
   {
nop;
nop;
nop;
nop;
   }
  }
}
/*
uchar lcd_bz()
{ // 测试LCD忙碌状态bit7
uchar result=0x80;
        P3DIR =0x00;///
RS_0;
RW_1;
E_1;
  //nop;
//nop;
//nop;
nop;
result = (uchar)(P3IN & 0x80);
        if(result == 0)
          nop;
E_0;
return (result);
}

void write_cmd(uchar cmd)
{ // 写入指令数据到LCD
//while(lcd_bz() & 0x80);
   E_0;
   P3DIR = 0xff; ///
   RS_0;
   RW_0;

//nop;
//nop;
   P3OUT = cmd;
//nop;
//nop;
//nop;
//nop;
   E_1;
   nop;
//nop;
//nop;
//nop;
   E_0;
}

void lcd_pos(uchar pos)
{ //设定显示位置
  //while(lcd_bz() & 0x80);
  writecmd(pos | 0x80);
}

void write_data(uchar dat)
{ //写入字符显示数据到LCD
  //while(lcd_bz() & 0x80);
  P3DIR =  0x00;             // 置位输入模式
  RW_1;
  RS_0;
  E_1;
  //while((P3IN & 0x80)==0x80);//检测LCD是否忙
  E_0;
  P3DIR = 0xff; ///
  RS_0;
  RW_0;
  RS_1; //
//E_0;
  P3OUT = dat;
//nop;
//nop;
//nop;
//nop;
  E_1;
//nop;
//nop;
//nop;
  nop;
  E_0;
}
*/
void delay_us(uchar de)
{  while(de-- >0)
      nop;
}
//((((((((((((((((((((((((((((((
void busy_check()
{
  P3DIR = 0;
  E_0; //

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      19242  2011-03-04 16:09  LCD1602\Debug\Exe\LCD1602.d43

     文件        133  2011-03-04 16:09  LCD1602\Debug\Obj\LCD1602.pbd

     文件      21482  2011-03-04 16:09  LCD1602\Debug\Obj\main.r43

     文件       5208  2011-03-04 16:03  LCD1602\LCD1602.c

     文件       2121  2011-03-04 16:23  LCD1602\LCD1602.dep

     文件      17879  2011-03-03 21:50  LCD1602\LCD1602.ewd

     文件      47478  2011-03-03 21:50  LCD1602\LCD1602.ewp

     文件        161  2011-03-03 21:50  LCD1602\LCD1602.eww

     文件        901  2011-03-04 16:09  LCD1602\main.c

     文件       2729  2011-03-04 16:10  LCD1602\settings\LCD1602.cspy.bat

     文件       5545  2011-03-04 16:23  LCD1602\settings\LCD1602.dbgdt

     文件       1188  2011-03-04 16:23  LCD1602\settings\LCD1602.dni

     文件       3404  2011-03-04 16:23  LCD1602\settings\LCD1602.wsdt

     目录          0  2011-03-04 15:12  LCD1602\Debug\Exe

     目录          0  2011-03-03 21:42  LCD1602\Debug\List

     目录          0  2011-03-04 16:23  LCD1602\Debug\Obj

     目录          0  2011-03-03 21:42  LCD1602\Debug

     目录          0  2011-03-03 22:29  LCD1602\settings

     目录          0  2011-03-04 16:09  LCD1602

----------- ---------  ---------- -----  ----

               127471                    19


评论

共有 条评论