#include<htc.h>
#define rd RE0
#define wr RE1
#define cs RE2
void pspint();
void pspsend();
void elay(int);
void elay(int s)
{
while(s--);
}
void pspsend()
{
rd=1;
elay(200);
wr=0;
PORTD=0b11111111;
//while(PSPIF==0);
//PSPIF=0;
cs=1;
elay(200);
cs=0;
}
void pspint()
{
TRISE=0x10;
}
void main()
{
ADCON1=0x06;
//TRISE=0X00;
TRISD=0X00;
pspint();
while(1)
{
elay(6500);
pspsend();
elay(6500);
}
}
#define rd RE0
#define wr RE1
#define cs RE2
void pspint();
void pspsend();
void elay(int);
void elay(int s)
{
while(s--);
}
void pspsend()
{
rd=1;
elay(200);
wr=0;
PORTD=0b11111111;
//while(PSPIF==0);
//PSPIF=0;
cs=1;
elay(200);
cs=0;
}
void pspint()
{
TRISE=0x10;
}
void main()
{
ADCON1=0x06;
//TRISE=0X00;
TRISD=0X00;
pspint();
while(1)
{
elay(6500);
pspsend();
elay(6500);
}
}
#define rs RC0
#define rw RC1
#define en RC2
int count=0;
int adc=0;
int p=192;
void lcdint();
void lcddisp(char chr);
void lcdcmd(int cmd);
void delay(int s);
void lcdstr(unsigned char *str);
void lcddisp1(char);
void delay(int s)
{
while(s--);
}
void lcdint()
{
lcdcmd(0x38);
lcdcmd(0x01);
lcdcmd(0x0E);
lcdcmd(0x06);
lcdcmd(0x80);
}
void lcdread()
{
char chrrd;
rw=1;
rs=1;
chrrd=PORTD;
en=1;
delay(100);
en=0;
}
void lcddisp(char chr)
{
if(count==16)
{
lcdcmd(0x80);
lcdstr(" ");
lcdcmd(0x80);
count=0;
}
if(adc==1)
{
lcdcmd(p);
rw=0;
rs=1;
PORTD=chr;
en=1;
delay(100);
en=0;
p++;
}
rw=0;
rs=1;
PORTD=chr;
en=1;
delay(100);
en=0;
count++;
}
void lcdcmd(int cmd)
{
rw=0;
rs=0;
PORTD=cmd;
en=1;
delay(100);
en=0;
if(cmd==0x01)
count=0;
}
void lcddisp1(char disp1)
{
rw=0;
rs=1;
PORTD=disp1;
en=1;
delay(100);
en=0;
}
void lcdstr(unsigned char *str)
{
while(*str)
{
delay(2500);
lcddisp1(*str++);
}
}
No comments:
Post a Comment