#include<pic.h>
#include<htc.h>
#define __PIC16F628A_H
#define led PORTBbits.RD0
__CONFIG(FOSC_HS & WDTE_OFF & PWRTE_ON & MCLRE_ON & BOREN_ON & LVP_OFF & CPD_OFF & CP_OFF);
unsigned int x;
void delay(unsigned int i)
{
while(i--);
}
void cmd(unsigned char c)
{
unsigned int l,h;
h=c &0XF0;
l=c<<4;
PORTB=h|0X04;
delay(20);
PORTB=h|0X00;
PORTB=l|0X04;
delay(20);
PORTB=l|0X00;
}
void dat (unsigned char c)
{
unsigned int l,h;
h=c &0XF0;
l=c<<4;
PORTB=h|0X0C;
delay(20);
PORTB=h|0X08;
PORTB=l|0X0C;
delay(20);
PORTB=l|0X08;
}
void lcd_init()
{
cmd(0x02);
delay(100);
cmd(0x28);
delay(100);
cmd(0x01);
delay(100);
cmd(0x80);
delay(100);
cmd(0x0e);
delay(100);
}
void string(unsigned char *p)
{
while(*p!='\0')
{
dat(*p);
p++;
}
}
int main()
{
TRISB=0x00;
lcd_init();
string ("EMBEDDED_LAB");
//num(12345);
while(1);
}
No comments:
Post a Comment