-
Notifications
You must be signed in to change notification settings - Fork 0
/
LAB12.c
141 lines (115 loc) · 2.01 KB
/
LAB12.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#include<lpc214x.h>
#include<stdio.h>
//Function prototypes
void lcd_init(void);
void wr_cn(void);
void clr_disp(void);
void delay(unsigned int);
void lcd_com(void);
void wr_dn(void);
void lcd_data(void);
unsigned char temp1;
unsigned long int temp,r=0;
unsigned char *ptr,disp[] = " HI HELLO ",disp1[] = "HOW ARE YOU";
int main()
{
PINSEL0 = 0X00000000;
IO0DIR = 0x000000FC;
lcd_init();
delay(3200);
clr_disp();
delay(3200);
temp1 = 0x81;
lcd_com();
ptr = disp;
while(*ptr!='\0')
{
temp1 = *ptr;
lcd_data();
ptr ++;
}
temp1 = 0xC0;
lcd_com();
ptr = disp1;
while(*ptr!='\0')
{
temp1 = *ptr;
lcd_data();
ptr ++;
}
while(1);
}
void lcd_init(void)
{
temp = 0x30;
wr_cn();
delay(3200);
temp = 0x30;
wr_cn();
delay(3200);
temp = 0x30;
wr_cn();
delay(3200);
temp = 0x20;
wr_cn();
delay(3200);
temp1 = 0x28;
lcd_com();
delay(3200);
temp1 = 0x0C;
lcd_com();
delay(800);
temp1 = 0x06;
lcd_com();
delay(800);
temp1 = 0x80;
lcd_com();
delay(800);
}
void lcd_com(void)
{
temp = temp1 & 0xf0;
wr_cn();
temp = temp1 & 0x0f;
temp = temp << 4;
wr_cn();
delay(500);
}
void wr_cn(void)
{
IO0CLR = 0x000000FC;
IO0SET = temp;
IO0CLR = 0x00000004;
IO0SET = 0x00000008;
delay(10);
IO0CLR = 0x00000008;
}
void wr_dn(void)
{
IO0CLR = 0x000000FC;
IO0SET = temp;
IO0SET = 0x00000004;
IO0SET = 0x00000008;
delay(10);
IO0CLR = 0x00000008;
}
void lcd_data(void)
{
temp = temp1 & 0xf0;
temp = temp ;//<< 6;
wr_dn();
temp= temp1 & 0x0f;
temp= temp << 4;
wr_dn();
delay(100);
}
void clr_disp(void)
{
temp1 = 0x01;
lcd_com();
delay(500);
}
void delay(unsigned int r1)
{
for(r=0;r<r1;r++);
}