#include<htc.h>
#include"lcdsub.c"
#define ss RC0
void elay(int);
void spiint();
void spisend(unsigned char);
void spisend(unsigned char dat)
{
SSPBUF=dat;
while(BF==0);
BF=0;
}
void spiint()
{
SSPSTAT=0xc0;
SSPCON=0x31;
}
void elay(int s)
{
while(s--);
}
void main()
{
TRISB=0x00;
TRISD=0x00;
TRISC=0x00;
TRISC3=0;
TRISC4=1;
TRISC5=0;
lcdint();
spiint();
lcdstr("INTZNG master");
elay(15000);
lcdcmd(0x01);
while(1)
{
TRISC6=0;
TRISC7=1;
ss=0;
elay(6500);
lcdstr("sending data");
lcdcmd(0xc0);
lcddisp('a');
spisend('a');
elay(65000);
lcdcmd(0x01);
}
}
#include"lcdsub.c"
#define ss RC0
void elay(int);
void spiint();
void spisend(unsigned char);
void spisend(unsigned char dat)
{
SSPBUF=dat;
while(BF==0);
BF=0;
}
void spiint()
{
SSPSTAT=0xc0;
SSPCON=0x31;
}
void elay(int s)
{
while(s--);
}
void main()
{
TRISB=0x00;
TRISD=0x00;
TRISC=0x00;
TRISC3=0;
TRISC4=1;
TRISC5=0;
lcdint();
spiint();
lcdstr("INTZNG master");
elay(15000);
lcdcmd(0x01);
while(1)
{
TRISC6=0;
TRISC7=1;
ss=0;
elay(6500);
lcdstr("sending data");
lcdcmd(0xc0);
lcddisp('a');
spisend('a');
elay(65000);
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 delay(int s);
void lcdstr(unsigned char *str);
void lcddisp2(int hr,int min,int sec);
void lcddisp1(char);
void lcdint();
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