分享到:
#include <msp430x14x.h>
typedef unsigned char uchar;
typedef unsigned int uint;
extern const unsigned char shuzi_table[];
#define LCD_CMDOut P6DIR|=0xff //P6口的三位设置为输出
#define LCD_RS_H P6OUT|=BIT3 //P6.3
#define LCD_RS_L P6OUT&=~BIT3 //P6.3
#define LCD_RW_H P6OUT|=BIT4 //P6.4
#define LCD_RW_L P6OUT&=~BIT4 //P6.4
#define LCD_EN_H P6OUT|=BIT5 //P6.5
#define LCD_EN_L P6OUT&=~BIT5 //P6.5
/*******************************************
函数名称:Delay_1ms
功 能:延时约1ms的时间
参 数:无
返回值 :无
********************************************/
void Delay_1ms(void)
{
uchar i;
for(i = 150;i > 0;i--) _NOP();
}
/*******************************************
函数名称:Delay_Nms
功 能:延时N个1ms的时间
参 数:n--延时长度
返回值 :无
********************************************/
void Delay_Nms(uint n)
{
uint i;
for(i = n;i > 0;i--) Delay_1ms();
}
//LCD12864发送函数
//入口参数:Data_Command(要发送的数据或命令)
//返回值:无
//说明:串行通信方式
void LCD12864_Send(uchar Data_Command)
{
uchar i;
LCD_RS_H ; //CS为高电平,使能CS
for(i=0;i<8;i++)
{
if((Data_Command & 0x80)!=0) //发送的是1
LCD_RW_H ; //SID为高电平
else
if(((Data_Command & 0x80)==0)) //发送的是0
LCD_RW_L; //SID为低电平
LCD_EN_H; //SCLK为高电平
LCD_EN_L; //SCLK为低电平
Data_Command<<=1; //完成一次发送后数据左移一位,等待第二次发送
}
LCD_RS_L; //CS为低电平,失能CS
}
typedef unsigned char uchar;
typedef unsigned int uint;
extern const unsigned char shuzi_table[];
#define LCD_CMDOut P6DIR|=0xff //P6口的三位设置为输出
#define LCD_RS_H P6OUT|=BIT3 //P6.3
#define LCD_RS_L P6OUT&=~BIT3 //P6.3
#define LCD_RW_H P6OUT|=BIT4 //P6.4
#define LCD_RW_L P6OUT&=~BIT4 //P6.4
#define LCD_EN_H P6OUT|=BIT5 //P6.5
#define LCD_EN_L P6OUT&=~BIT5 //P6.5
/*******************************************
函数名称:Delay_1ms
功 能:延时约1ms的时间
参 数:无
返回值 :无
********************************************/
void Delay_1ms(void)
{
uchar i;
for(i = 150;i > 0;i--) _NOP();
}
/*******************************************
函数名称:Delay_Nms
功 能:延时N个1ms的时间
参 数:n--延时长度
返回值 :无
********************************************/
void Delay_Nms(uint n)
{
uint i;
for(i = n;i > 0;i--) Delay_1ms();
}
//LCD12864发送函数
//入口参数:Data_Command(要发送的数据或命令)
//返回值:无
//说明:串行通信方式
void LCD12864_Send(uchar Data_Command)
{
uchar i;
LCD_RS_H ; //CS为高电平,使能CS
for(i=0;i<8;i++)
{
if((Data_Command & 0x80)!=0) //发送的是1
LCD_RW_H ; //SID为高电平
else
if(((Data_Command & 0x80)==0)) //发送的是0
LCD_RW_L; //SID为低电平
LCD_EN_H; //SCLK为高电平
LCD_EN_L; //SCLK为低电平
Data_Command<<=1; //完成一次发送后数据左移一位,等待第二次发送
}
LCD_RS_L; //CS为低电平,失能CS
}
(1 )
(0 )


-
- 少年的你没有退路可言
-
160 发帖627 回复2747 积分
- 私信他 +关注
-
- 少年的你没有退路可言
-
160 发帖627 回复2747 积分
- 私信他 +关注
-
- 少年的你没有退路可言
-
160 发帖627 回复2747 积分
- 私信他 +关注
-
- 少年的你没有退路可言
-
160 发帖627 回复2747 积分
- 私信他 +关注
-
- 少年的你没有退路可言
-
160 发帖627 回复2747 积分
- 私信他 +关注
发表回复
块
导
航
举报
请选择举报类别
- 广告垃圾
- 违规内容
- 恶意灌水
- 重复发帖