#include<htc.h>
#include"lcdsub.c"
void elay(int);
unsigned char spiread(void);
void spiintslave();
void spiintslave()
{
SSPSTAT=0x40;
SSPCON=0x34;
}
unsigned char spiread()
{
unsigned char data1;
while(BF==0);
data1=SSPBUF;
BF=0;
return data1;
}
void elay(int s)
{
while(s--);
}
void main()
{
TRISA=0X00;
TRISD=0x00;
TRISB=0x00;
TRISC3=1;
TRISC4=1;
TRISA5=0;
lcdint();
spiintslave();
lcdstr("INTZNG SLAVE");
elay(6500);
lcdcmd(0x01);
unsigned char rx;
lcdstr("receiving data");
lcdcmd(0xc0);
while(1)
{
rx=spiread();
lcddisp(rx);
elay(6500);
//lcdcmd(0x01);
}
}
#include"lcdsub.c"
void elay(int);
unsigned char spiread(void);
void spiintslave();
void spiintslave()
{
SSPSTAT=0x40;
SSPCON=0x34;
}
unsigned char spiread()
{
unsigned char data1;
while(BF==0);
data1=SSPBUF;
BF=0;
return data1;
}
void elay(int s)
{
while(s--);
}
void main()
{
TRISA=0X00;
TRISD=0x00;
TRISB=0x00;
TRISC3=1;
TRISC4=1;
TRISA5=0;
lcdint();
spiintslave();
lcdstr("INTZNG SLAVE");
elay(6500);
lcdcmd(0x01);
unsigned char rx;
lcdstr("receiving data");
lcdcmd(0xc0);
while(1)
{
rx=spiread();
lcddisp(rx);
elay(6500);
//lcdcmd(0x01);
}
}
#define rs RB0
#define rw RB1
#define en RB2
int count=0;
int adc=0;
int p=192;
void lcddisp(char);
void lcdcmd(int cmd);
void lcdint();
void delay(int s);
void lcdstr(unsigned char *str);
void lcddisp2(int hr,int min,int sec);
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)
{
rw=0;
rs=1;
PORTD=chr;
en=1;
delay(100);
en=0;
}
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++);
}
}
void lcddisp2(int hr,int min,int sec)
{
count=0;
lcdcmd(0x01);
lcdcmd(0x84);
lcddisp((hr/10)+0x30);
lcddisp((hr%10)+0x30);
lcddisp(':');
lcddisp((min/10)+0x30);
lcddisp((min%10)+0x30);
lcddisp(':');
lcddisp((sec/10)+0x30);
lcddisp((sec%10)+0x30);
}
No comments:
Post a Comment