📄 lcd-2007-05-28-21d.txt
字号:
//2007-5-28-21:00 点亮
#include <msp430x14x.h>
#include <stdio.h>
unsigned char state;
unsigned char temp;
unsigned char page;
unsigned char picture[];
unsigned char high;
unsigned char low;
void Init_lcd(void);
void LCD_DataWrite(char Data);
void Lcd_InsWrite(char Instruction);
void Delay(int m);
void clear_screen();
/******************显示*****************/
void main(void)
{
char i;
WDTCTL=WDTPW+WDTHOLD;
P1DIR |= 0x01; // Set P1.0 to output direction
P1OUT ^= 0x01; // Toggle P1.0 using exclusive-OR
Init_lcd();
for(i=0;i<1;i++)
{
Lcd_InsWrite(0x00); //第一行
Delay(30000); P1OUT ^= 0x01;
LCD_DataWrite(0xbb); //
Delay(30000); P1OUT ^= 0x01;
LCD_DataWrite(0xb6);
// clear_screen();
Delay(30100);P1OUT ^= 0x01;
Delay(30100);P1OUT ^= 0x01;
Delay(30100);P1OUT ^= 0x01;
LCD_DataWrite(0xb6);
LCD_DataWrite(0xd3); //
Delay(30000); P1OUT ^= 0x01;
LCD_DataWrite(0xad);
Delay(30000); P1OUT ^= 0x01;
LCD_DataWrite(0xca); //
Delay(30000); P1OUT ^= 0x01;
LCD_DataWrite(0xb9);
LCD_DataWrite(0xd3); //
LCD_DataWrite(0xc3);
Lcd_InsWrite(0x94); //2行
LCD_DataWrite(0xce); //
LCD_DataWrite(0xde);
LCD_DataWrite(0xcf); //
LCD_DataWrite(0xdf);
LCD_DataWrite(0xb3); //
LCD_DataWrite(0xad);
LCD_DataWrite(0xb1); //表
LCD_DataWrite(0xed);
LCD_DataWrite(0xa3); //!
LCD_DataWrite(0xa1);
Delay(5);
}
}
void Delay(int m)
{
int i=0;
for(i=0;i<m;i++);
}
/************初始化LCD***********************/
void Init_lcd(void)
{
P4DIR|=0XFF; //0B10111111 VCC=P47=1,NC=P46=0,DC=P45=1,WR=P44=1, RD=P43=1,CS=P42=1,CS=P41=1,RES=P40=1,//
P4OUT&=~ (BIT1+BIT2); //0B10011001 CS=P42=0,CS=P41=0
Delay(200);
P4OUT&=~BIT0; //;0B10011000 RES=P40=0复位,
Delay(200);
P4OUT|=BIT0; //0B10011001 RES=P40=1,
Delay(200);
P4OUT&=~BIT5; //0B10011001 DC=P45=0,
Delay(200);
P4OUT|=BIT3; //0B10011001 RD=P43=1,
Delay(200);
Lcd_InsWrite(0xAF);
Delay(400);
Lcd_InsWrite(0xA4); //
Delay(400);
Lcd_InsWrite(0xA6); //
Delay(400);
Lcd_InsWrite(0x81); //
Delay(400);
Lcd_InsWrite(0x80); //
Delay(400);
Lcd_InsWrite(0xA0);
Delay(400);
Lcd_InsWrite(0xC8); //
Delay(400);
Lcd_InsWrite(0xD8); //
Delay(400);
Lcd_InsWrite(0x00); //
Delay(400);
Lcd_InsWrite(0xDA); //
Delay(400);
Lcd_InsWrite(0x12); //
Delay(400);
}
/********************写指令****************************/
void Lcd_InsWrite(char Instruction)
{
P4DIR|=0XFF; //0B10111111 VCC=P47=1,NC=P46=0,DC=P45=1,WR=P44=1, RD=P43=1,CS=P42=1,CS=P41=1,RES=P40=1,//
P4OUT&=~BIT5; //0B10011001 DC=P45=0,
Delay(200);
P5DIR=0XFF;
P5OUT=Instruction; //功能设定
Delay(200);
P4OUT&=~ (BIT1+BIT2); //0B10011001 CS=P42=0,CS=P41=0
Delay(200);
P4OUT&=~BIT4; //0B10011000 WR=P44=0 ,
Delay(200);
P4OUT|=BIT4; //0B10011001 WR=P44=1,
Delay(200);
P4OUT|= (BIT1+BIT2); //0B10011001 CS=P42=0,CS=P41=0
Delay(200);
}
/****LCD_WRITE.C 显示文字*******************/
void LCD_DataWrite(char Data)
{
P4DIR|=0XFF; //0B10111111 VCC=P47=1,NC=P46=0,DC=P45=1,WR=P44=1, RD=P43=1,CS=P42=1,CS=P41=1,RES=P40=1,//
P4OUT|=BIT5; //0B10011001 DC=P45=1,
Delay(200);
P5DIR=0XFF;
P5OUT=Data; //功能设定
Delay(200);
P4OUT&=~ (BIT1+BIT2); //0B10011001 CS=P42=0,CS=P41=0
Delay(200);
P4OUT&=~BIT4; //0B10011000 WR=P44=0 ,
Delay(200);
P4OUT|=BIT4; //0B10011001 WR=P44=1,
Delay(200);
P4OUT|= (BIT1+BIT2); //0B10011001 CS=P42=1,CS=P41=1
Delay(200);
}
//================================================================
void clear_screen()
{
unsigned char j;
for(page=0;page<8;page++)
{
Lcd_InsWrite(176+page); //set page address
Lcd_InsWrite(0x00); //set low address
Lcd_InsWrite(0x10); //set higher address
for(j=0;j<128;j++)
{
LCD_DataWrite(0xff);
}
}
}
//================================================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -