|
#i nclude<pic.h>
//__CONFIG(3F39H);
#define RS RA1
#define RW RA2
#define E RA3
#define STA7 RC7
int temp;
void LCD_init(void);
void LCD_ORDER(int,int);
void LCD_DATA(int);
void Delay(void);
void LCD_BuysC(void);
void display(int,int,int);
void delaynop(int);
void delaynop(int i)
{
while(--i);
}
void LCD_init()
{
TRISC=0x00;
LCD_ORDER(0x01,0);
LCD_ORDER(0x38,0);
LCD_ORDER(0x0F,0);
LCD_ORDER(0x06,0);
LCD_ORDER(0x80,0);
/* PORTC=temp;
RS=1;
RW=0;
E=1;
asm("nop");
asm("nop");
E=0;*/
}
void LCD_BuysC()
{
RS=0;
RW=1;
E=0;
NOP();
TRISC7=1;
E=1;
while(RC7==1 )
{
RS=0;
RW=1;
E=0;
NOP();
E=1;
}
TRISC=0x00;
}
void LCD_ORDER(int order,int BuysC)
{
RS=0;
RW=0;
PORTC=order;
E=1;
asm("nop");
asm("nop");
E=0;
delaynop(5000);
}
void LCD_DATA(int dat)
{
PORTC=dat;
RS=1;
RW=0;
E=1;
asm("nop");
asm("nop");
E=0;
delaynop(5000);
}
void Delay(void)
{
int TempCyc = 1552;
while(--TempCyc);
}
void display(int x,int y,int dat)
{
y&=0x01;
x&=0x0f;
if(y)
x|=0x40;
x|=0x80;
LCD_ORDER(x,0);
LCD_DATA(dat);
}
void main()
{
temp='3';
ADCON1=0X07;
TRISC=0x00;
TRISA1=0;
TRISA2=0;
TRISA3=0;
Delay();
LCD_init();
display(1,1,temp);
while(1);
}
|
|