vijaynallasivam
Junior Member level 1
- Joined
- Nov 16, 2015
- Messages
- 16
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 150
Code C - [expand] 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 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 header f void CheckBusy() { TRISD = 0xff; do { RE0 = 0; RE1 = 1; RE2 = 1; DelayUs(20); RE2 = 0; }while(RD7); TRISD = 0x00; PORTD = 0x00; } void LCD_SendCmd1(unsigned char cmd) { PORTD = cmd; RE0 = 0; RE1 = 0; RE2 = 1; DelayUs(20); RE2 = 0; } void LCD_SendCmd(unsigned char cmd) { CheckBusy(); PORTD = cmd; RE0 = 0; RE1 = 0; RE2 = 1; DelayUs(20); RE2 = 0; } void LCD_SendData(unsigned char dat) { CheckBusy(); PORTD = dat; RE0 = 1; RE1 = 0; RE2 = 1; DelayUs(20); RE2 = 0; } void ClearLine(short int st) { short int l; for(l=0;l<=15;l++) { LCD_SendCmd(st+l); LCD_SendData(' '); } } void LCD_init() { LCD_SendCmd1(0x38); DelayMs(100); LCD_SendCmd1(0x38); DelayMs(100); LCD_SendCmd1(0x38); DelayMs(100); LCD_SendCmd(0x06); DelayUs(100); LCD_SendCmd(0x0c); DelayUs(100); LCD_SendCmd(0x01); DelayUs(100); LCD_SendCmd(0x02); asm("CLRWDT"); } void LCD_puts(const char * s) { while(*s) { LCD_SendData(*s++); } } program code: #include<pic.h> #include<string.h> #include<stdio.h> #include<lcd.h> #include<uart.h> #define _XTAL_FREQ 20e6 __CONFIG(0x3F3A); void main() { unsigned char i,temp,database; unsigned char data[12]; TRISA = 0xff; TRISC = 0x92; TRISD = 0x00; TRISB = 0x00; TRISE = 0x00; PORTB = 0x00; PORTD = 0x00; PORTE = 0x00; PORTC = 0x02; ADCON1 =0x86; SPBRG = 25; BRGH = 1; TXEN = 1; CREN = 1; SPEN = 1; send_config(0b00000001); send_config(0b00000010); send_config(0b00000110); send_config(0b00001100); send_config(0b00111000); lcd_clr(); lcd_goto(0); send_string("WELCOME"); lcd_goto(20); send_string("STARTING UP....."); delay(300000); while(1) { delay(5000); CREN = 1; database=0; lcd_clr(); lcd_goto(0); send_string("Place your ID"); lcd_goto(20); send_string("on the reader."); temp=0; for(i=0;i<=12;i++)data[i]=uart_rec(); if(temp==0) { lcd_clr(); lcd_goto(0); send_string("ID:"); for(i=1;i<=10;i++)send_char(data[i]); } CREN = 0; delay(300000); } }
lcd init in header file separate file
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 void LCD_init() { LCD_SendCmd1(0x38); DelayMs(100); LCD_SendCmd1(0x38); DelayMs(100); LCD_SendCmd1(0x38); DelayMs(100); LCD_SendCmd(0x06); DelayUs(100); LCD_SendCmd(0x0c); DelayUs(100); LCD_SendCmd(0x01); DelayUs(100); LCD_SendCmd(0x02); asm("CLRWDT"); }
void LCD_Init()
{
RS_PIN = 0; //LCD instructions (RS) pin no. 4
Chr_LCD(0x38); //LCD 8 Bit Data
Chr_LCD(0x01); //LCD clear
Chr_LCD(0x0C); //LCD diplay on cursor not blinking
Chr_LCD(0x80); //LCD cursor Pos. begain
RS_PIN = 1; //LCD DATA (RS) pin no. 4
}
void Chr_LCD(char data)
{
DATA_PORT = data;
E_PIN = 1;
Time_10ms();
E_PIN = 0;
Time_10ms();
}
Hi,
The OP already has the LCD_init routine...
but the problem is that he never calls this routine....
Klaus
#define rs RE0
#define rw RE1
#define e RE2
#define lcd_data PORTD
void delay(unsigned long data);
void send_config(unsigned char data);
void send_char(unsigned char data);
void lcd_goto(unsigned char data);
void lcd_clr(void);
void send_string(const char *s);
void delay(unsigned long data)
{
for( ;data>0;data-=1);
}
void send_config(unsigned char data)
{
rw=0;
rs=0;
lcd_data=data;
e=1;
delay(50);
e=0;
delay(50);
}
void send_char(unsigned char data)
{
rw=0;
rs=1;
lcd_data=data;
e=1;
delay(10);
e=0;
delay(10);
}
void lcd_goto(unsigned char data)
{
if(data<16)
{
send_config(0x80+data);
}
else
{
data=data-20;
send_config(0xc0+data);
}
}
void lcd_clr(void)
{
send_config(0x01);
delay(600);
}
void send_string(const char *s)
{
unsigned char i=0;
while (s && *s)send_char (*s++);
}
[U]my program:[/U]
#include<pic.h>
#include<string.h>
#include<stdio.h>
#include<lcd.h>
#include<uart.h>
#define _XTAL_FREQ 20e6
__CONFIG(0x3F3A);
void main()
{
unsigned char i,temp,database;
unsigned char data[12];
TRISA = 0xff;
TRISC = 0x92;
TRISD = 0x00;
TRISB = 0x00;
TRISE = 0x00;
PORTB = 0x00;
PORTD = 0x00;
PORTE = 0x00;
PORTC = 0x02;
ADCON1 =0x86;
SPBRG = 25;
BRGH = 1;
TXEN = 1;
CREN = 1;
SPEN = 1;
send_config(0b00000001);
send_config(0b00000010);
send_config(0b00000110);
send_config(0b00001100);
send_config(0b00111000);
lcd_clr();
lcd_goto(0);
send_string("WELCOME");
lcd_goto(20);
send_string("STARTING UP.....");
delay(300000);
while(1)
{
delay(5000);
CREN = 1;
database=0;
lcd_clr();
lcd_goto(0);
send_string("Place your ID");
lcd_goto(20);
send_string("on the reader.");
temp=0;
for(i=0;i<=12;i++)data[i]=uart_rec();
if(temp==0)
{
lcd_clr();
lcd_goto(0);
send_string("ID:");
for(i=1;i<=10;i++)send_char(data[i]);
}
CREN = 0;
delay(300000);
}
}
[COLOR=#333333][FONT=Verdana] Delay(100000); //delai for power stabilisation[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]send_config(0b00000001); Delay(10000);[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]send_config(0b00000010); [/FONT][/COLOR][COLOR=#333333][FONT=Verdana] Delay(10000);[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]send_config(0b00000110); [/FONT][/COLOR][COLOR=#333333][FONT=Verdana] Delay(10000);[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]send_config(0b00001100); [/FONT][/COLOR][COLOR=#333333][FONT=Verdana] Delay(10000);[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]send_config(0b00111000); [/FONT][/COLOR][COLOR=#333333][FONT=Verdana] Delay(10000);[/FONT][/COLOR]
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?