#include<htc.h>
#include "lcdsub.c"
#define ss RC0
void spi_init();
void spi_tx(unsigned char dat);
void spi_str(unsigned char *s);
void spi_init()
{
SSPSTAT = 0xC0;
SSPCON = 0x31;
//SSPCON=0x20;
}
void spi_tx(unsigned char dat)
{
SSPBUF = dat;
while(BF==0);
BF=0;
// return SSPBUF;
delay(5000);
}
void spi_str(unsigned char *s)
{
while(*s)
{
delay(65000);
spi_tx(*s++);
delay(65000);
}
}
void main()
{
TRISA=0xFF;
TRISE0=0;
TRISE1=0;
TRISE2=0;
TRISD=0x00;
TRISC3=0;
TRISC4=1;
TRISC5=0;
ADCON1=0x82;
TRISC6=0;TRISC7=1;
lcd_init();
spi_init();
lcd_cmd(0x80);
lcd_str(" SPI SAMPLE ");
lcd_cmd(0xc0);
lcd_str(" PROGRAM ");
delay(65500);//delay(65500);
// delay(65500);//delay(65500);
lcd_cmd(0x80);
lcd_str(" ");
lcd_cmd(0xc0);
lcd_str(" ");
while(1)
{
ss=0;
//delay(65500); delay(65500);
//spi_tx('s')
spi_str("-abcdefghijklmnopqrstuvwxyz---are english alphabets*");
lcd_cmd(0x80);
lcd_data('a');
//delay(65500);//delay(65500); delay(65500);delay(65500);
lcd_cmd(0x01);
}
}
void lcd_data(unsigned char);
void lcd_cmd(unsigned char);
void lcd_str(char* );
void delay(unsigned int);
void lcd_init();
void lcd_init()
{
lcd_cmd(0x0E);
lcd_cmd(0x80);
lcd_cmd(0x38);
}
void lcd_data(unsigned char lcd_val)
{
PORTD=lcd_val;
RE2=1;
RE1=0;
RE0=1;
delay(100);
RE0=0;
}
void lcd_cmd(unsigned char lcd_val)
{
PORTD=lcd_val;
RE2=0;
RE1=0;
RE0=1;
delay(6500);
RE0=0;
}
void lcd_str(char *lcd_str1)
{
while(*lcd_str1)
{
lcd_data(*lcd_str1++);
}
}
void delay(unsigned int del)
{
while(del--);
}
#include "lcdsub.c"
#define ss RC0
void spi_init();
void spi_tx(unsigned char dat);
void spi_str(unsigned char *s);
void spi_init()
{
SSPSTAT = 0xC0;
SSPCON = 0x31;
//SSPCON=0x20;
}
void spi_tx(unsigned char dat)
{
SSPBUF = dat;
while(BF==0);
BF=0;
// return SSPBUF;
delay(5000);
}
void spi_str(unsigned char *s)
{
while(*s)
{
delay(65000);
spi_tx(*s++);
delay(65000);
}
}
void main()
{
TRISA=0xFF;
TRISE0=0;
TRISE1=0;
TRISE2=0;
TRISD=0x00;
TRISC3=0;
TRISC4=1;
TRISC5=0;
ADCON1=0x82;
TRISC6=0;TRISC7=1;
lcd_init();
spi_init();
lcd_cmd(0x80);
lcd_str(" SPI SAMPLE ");
lcd_cmd(0xc0);
lcd_str(" PROGRAM ");
delay(65500);//delay(65500);
// delay(65500);//delay(65500);
lcd_cmd(0x80);
lcd_str(" ");
lcd_cmd(0xc0);
lcd_str(" ");
while(1)
{
ss=0;
//delay(65500); delay(65500);
//spi_tx('s')
spi_str("-abcdefghijklmnopqrstuvwxyz---are english alphabets*");
lcd_cmd(0x80);
lcd_data('a');
//delay(65500);//delay(65500); delay(65500);delay(65500);
lcd_cmd(0x01);
}
}
void lcd_data(unsigned char);
void lcd_cmd(unsigned char);
void lcd_str(char* );
void delay(unsigned int);
void lcd_init();
void lcd_init()
{
lcd_cmd(0x0E);
lcd_cmd(0x80);
lcd_cmd(0x38);
}
void lcd_data(unsigned char lcd_val)
{
PORTD=lcd_val;
RE2=1;
RE1=0;
RE0=1;
delay(100);
RE0=0;
}
void lcd_cmd(unsigned char lcd_val)
{
PORTD=lcd_val;
RE2=0;
RE1=0;
RE0=1;
delay(6500);
RE0=0;
}
void lcd_str(char *lcd_str1)
{
while(*lcd_str1)
{
lcd_data(*lcd_str1++);
}
}
void delay(unsigned int del)
{
while(del--);
}
No comments:
Post a Comment