BISH
Junior Member level 2
- Joined
- Nov 3, 2012
- Messages
- 23
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,418
hi all,
as ww already discussed the topic regarding 4 bit lcd..but,now i'm facing a problem with
4 BIT LCD DISPLAY IN PROTEUS...The coding s working well in PIC SIMULATOR.
pls correct me...attachment shows my coding and proteus simulation.
as ww already discussed the topic regarding 4 bit lcd..but,now i'm facing a problem with
4 BIT LCD DISPLAY IN PROTEUS...The coding s working well in PIC SIMULATOR.
pls correct me...attachment shows my coding and proteus simulation.
Code:
#include<pic.h>
#define RS RB2
#define EN RB1
#define databits PORTD
void Delay(unsigned int );
/*----------------PIC INITIALIZATION------------*/
void pic_init()
{
TRISB2 = 0;
TRISB1 = 0;
TRISD = 0;
}
/*-------------LCD FUNCTIONS BEGIN--------------*/
void LCD_STROBE(void)
{
EN = 1;
Delay(20);
EN = 0;
}
void Lcd4_Write(unsigned char c)
{
RS = 1;
Delay(20);
databits = (c >> 4);
LCD_STROBE();
databits = (c);
LCD_STROBE();
}
void Lcd4_Command(unsigned char c)
{
RS = 0;
Delay(20);
databits = (c >> 4);
LCD_STROBE();
databits = (c);
LCD_STROBE();
}
void clear(void)
{
Lcd4_Command(0x01);
Delay(10);
}
void Lcd4_Init()
{
Delay(10);
Lcd4_Command(0x38);
Delay(10);
Lcd4_Command(0x38);
Delay(10);
Lcd4_Command(0x38);
Lcd4_Command(0x28); // Function set (4-bit interface, 2 lines, 5*7Pixels)
Lcd4_Command(0x28); // Function set (4-bit interface, 2 lines, 5*7Pixels)
Lcd4_Command(0x0c); // Make cursorinvisible
clear(); // Clear screen
Lcd4_Command(0x6); // Set entry Mode(auto increment of cursor)
}
void Lcd4_Display(const char *q)
{
while (*q) {
Lcd4_Write(*q++);
}
}
/*-------------LCD END--------------------*/
main()
{
Delay(10);
//pic_init();
TRISD=0x00;
TRISB=0x00;
Lcd4_Init();Delay(10);
TRISC = 0;
while (1) {
Lcd4_Command(0x80);
Lcd4_Write('B');
Lcd4_Command(0xc0);
Lcd4_Display("IT IS WORKING:-)");
}
}
void Delay(unsigned int del)
{
while(del--);
}