MicroC code For LCD

I found this in my scrap after a long time.. This is a MicroC sode for LCD driving. I think there are lots who will want to know so i thot will cramp it up into this place..

Its quite a large two pagecode. The code will be self-explanatory. just copy down the code and make a hex and load. Make aure you wire it up only as the circuitbelow shows. Thinkgs will then be fine i guess.

CODE:

unsigned short int msec1=0x00,msec2=0x00,sec1=0x00,sec2=0x00,min1=0x00,min2=0x00,read=0x00,read1=0x00,i=0x00;
void enable (void);
void calmu (void);

void calmu (void)
{
PORTB = 0x01;
enable();
PORTB = 0x38;
enable();
PORTB = 0x0c;
enable();
PORTB = 0x06;
enable();
PORTB = 0x80;
enable();

///Write
PORTC.f7 = 0x01;
enable();
PORTB = 0x38;
enable();
PORTC.f7 = 0x00;

}

void enable(void)
{
PORTC.f6 = 0x01;
Delay_ms(100);
PORTC.f6 = 0x00;
Delay_ms(100);
}

/// for dot 2E

void main()
{

msec1=0x00,msec2=0x00,sec1=0x00,sec2=0x00,min1=0x00,min2=0x00,read=0x00,read1=0x00,i=0x00;
TRISB = 0x00;
TRISC = 0x00;
PORTB = 0x00;
PORTC = 0x00;
ADCON1 = 0x06;
TRISD = 0x00;
PORTD = 0x00;
TRISD = 0xFF;

PORTB = 0x01;
enable();
PORTB = 0x38;
enable();
PORTB = 0x0c;
enable();
PORTB = 0x06;
enable();
PORTB = 0x80;
enable();

///Write
PORTC.f7 = 0x01;
enable();

PORTB = your value in hex eg 0x31 displays "1";
enable();
PORTB = your value in hex eg 0x32 displays "2";
enable();
// display alphabest by their corresponding equivalent hex

PORTC.f7 = 0x00;
}
}

THE CIRCUIT:


Madan

Advertisements

3 thoughts on “MicroC code For LCD

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s