-
Notifications
You must be signed in to change notification settings - Fork 0
/
lcd4bit_rtc.c
78 lines (71 loc) · 980 Bytes
/
lcd4bit_rtc.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include<reg51.h>
#include"header.h"
//#include <string.h>
sbit RS=P3^4;
sbit RW=P3^5;
sbit EN=P3^6;
void lcd_init()
{
lcd_cmd(0x2);//compulsory in hw curser set to home not clr
lcd_cmd(0x28);//init into 8 bitmode
lcd_cmd(0xe);//cursor on
lcd_cmd(0x1);//clr scr n set cursor to home
}
void lcd_data(u8 ch)
{
P0=ch>>4;
RS=1;
RW=0;
EN=1;
delay_ms(2);
EN=0;
P0=ch&0x0f;
RS=1;
RW=0;
EN=1;
delay_ms(2);
EN=0;
}
void lcd_cmd(u8 cmd)
{
P0=cmd>>4;
RS=0;
RW=0;
EN=1;
delay_ms(2);
EN=0;
P0=cmd&0x0f;
RS=0;
RW=0;
EN=1;
delay_ms(2);
EN=0;
}
void lcd_string(u8 *str)
{
while(*str)
{
lcd_data(*str);
str++;
}
}
void lcd_week(u8 day)
{
switch(day)
{
case 1: lcd_string("SUN");
break;
case 2: lcd_string("MON");
break;
case 3: lcd_string("TUE");
break;
case 4: lcd_string("WED");
break;
case 5: lcd_string("THU");
break;
case 6: lcd_string("FRI");
break;
case 7: lcd_string("SAT");
break;
}
}