-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlcd.c
67 lines (67 loc) · 877 Bytes
/
lcd.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
#include "lcd.h"
#include "lcd_defines.h"
#include <lpc21xx.h>
#include "defines.h"
#include "delay.h"
void CmdLCD(u8 ch)
{
IOCLR0|=1<<RS;
WRITEBYTE(IOPIN0,LCD_D,ch);
IOSET0|=1<<EN;
delay_us(1);
IOCLR0|=1<<EN;
delay_ms(2);
}
void Char_LCD(u8 ch)
{
IOSET0|=1<<RS;
WRITEBYTE(IOPIN0,LCD_D,ch);
IOSET0|=1<<EN;
delay_us(1);
IOCLR0|=1<<EN;
delay_ms(2);
}
void U32LCD(u32 n)
{
u8 a[10];
s32 i=0;
if(n==0)
{
Char_LCD('0');
}
else
{
while(n)
{
a[i]=(n%10)+48;
i++;
n/=10;
}
for(--i;i>=0;i--)
Char_LCD(a[i]);
}
}
void Str_lcd(u8 *p)
{
while(*p)
Char_LCD(*p++);
}
void Init_LCD(void)
{
IODIR0|=0xFF<<LCD_D;
IODIR0|=1<<RS;
IODIR0|=1<<EN;
IODIR0|=1<<18;
//IOCLR0|=1<<18;
delay_ms(15);
CmdLCD(0x30);
delay_ms(5);
CmdLCD(0x30);
delay_us(160);
CmdLCD(0x30);
delay_us(160);
CmdLCD(0x38);
CmdLCD(0x01);
CmdLCD(0x06);
CmdLCD(0x0f);
}