编译的问题
本帖最后由 winnie 于 2009-4-14 14:38 编辑# include <pic1674.h>;
# include <stdio.h>;
# defineCS2RB4 ; 为什么这样不能定义字节???????????
# defineD_IRB0 ;
# defineR_WRB1 ;
# defineCS1RB3 ;
char buf;
void lcd_busy(void) {
TRISC7=1;
D_I=0;
R_W=1;
while(1){
E=1;
asm ("nop");
if(!RC7)
break;
}
E=0;
TRISC7=0;
}
void set_xy(unsigned char x,unsigned char y) {
if (x>=64) {CS1=0;CS2=1;}
else {CS2=0;CS1=1;};
lcd_busy();
E=1;D_I=0;R_W=0:PORTC=0x40|x;E=0;
lcd_busy();
E=1;D_I=0;R_W=0:PORTC=0xb8|y;E=0;
}
void lw(unsigned char x,unsigned char y,unsigned char dd) {
set_xy(x,y);
lcd_busy();E=1;D_I=1;R_W=0:PORTC=dd;E=0;
}
void lcd_init(void) {
unsigned char x,y;
E=1;
D_I=0;
R_W=0;
PORTC=0x3f;
E=0;
for (y=0;y<8;y++) {
for (x=0;x<128;x++)
lw(x,y,0x00);
}
}
void initial(void){
TRISB0=0;
TRISB1=0;
TRISB2=0;
TRISB3=0;
TRISB4=0;
TRISC=0x00;
}
unsigned char hz[]={
0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xc0,0x80,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
//0x80,0x40,0xf0,0x0f,0x02,0x00,0xfe,0x92,0x92,0x81,0x91,0x92,0x92,0xfe,0x00,0x00,
//0x00,0x00,0x7f,0x00,0x40,0x20,0x11,0x0c,0x03,0x00,0x3f,0x40,0x40,0x41,0x78,0x00,
//0x00,0x10,0x10,0x10,0x90,0x70,0x00,0xff,0x20,0x60,0x90,0x08,0x04,0x00,0x00,0x00,
//0x10,0x10,0x08,0x06,0x01,0x40,0x80,0x7f,0x00,0x00,0x01,0x06,0x0c,0x18,0x08,0x00,
//0x10,0x10,0xf0,0x1f,0x10,0xf0,0x80,0x82,0x82,0x82,0xf2,0x8a,0x86,0x82,0x80,0x00,
//0x80,0x43,0x22,0x14,0x0c,0x73,0x20,0x00,0x40,0x80,0x7f,0x00,0x00,0x00,0x00,0x00,
//0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x3f,0xc2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
//0x00,0x40,0x20,0x10,0x0c,0x03,0x00,0x00,0x01,0x06,0x0c,0x18,0x30,0x60,0x20,0x00
};
void dh(unsigned char x,unsigned char y,unsigned char n) {
unsigned char i,dd;
for (i=0;i<16;i++) {
dd=hz;
lw(x+i,y,dd);
dd=hz;
lw(x+i,y+1,dd);
}
}
main(void)
{
initial();
lcd_init();
dh(0,0,0);
//dh(18,2,4);
for(;;){};
} 改如下:
# include <pic1674.h>
# include <stdio.h>
# defineCS2RB4
# defineD_IRB0
# defineR_WRB1
# defineCS1RB3
char buf;
bit E;//我添加上去的.
void lcd_busy(void) {
TRISC7=1;
D_I=0;
R_W=1;
while(1){
E=1;
asm ("nop");
if(!RC7)
break;
}
E=0;
TRISC7=0;
}
void set_xy(unsigned char x,unsigned char y) {
if (x>=64) {CS1=0;CS2=1;}
else {CS2=0;CS1=1;};
lcd_busy();
E=1;D_I=0;R_W=0:PORTC=0x40|x;E=0;
lcd_busy();
E=1;D_I=0;R_W=0:PORTC=0xb8|y;E=0;
}
void lw(unsigned char x,unsigned char y,unsigned char dd) {
set_xy(x,y);
lcd_busy();E=1;D_I=1;R_W=0:PORTC=dd;E=0;
}
void lcd_init(void) {
unsigned char x,y;
E=1;
D_I=0;
R_W=0;
PORTC=0x3f;
E=0;
for (y=0;y<8;y++) {
for (x=0;x<128;x++)
lw(x,y,0x00);
}
}
void initial(void){
TRISB0=0;
TRISB1=0;
TRISB2=0;
TRISB3=0;
TRISB4=0;
TRISC=0x00;
}
unsigned char hz[]={
0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xc0,0x80,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
//0x80,0x40,0xf0,0x0f,0x02,0x00,0xfe,0x92,0x92,0x81,0x91,0x92,0x92,0xfe,0x00,0x00,
//0x00,0x00,0x7f,0x00,0x40,0x20,0x11,0x0c,0x03,0x00,0x3f,0x40,0x40,0x41,0x78,0x00,
//0x00,0x10,0x10,0x10,0x90,0x70,0x00,0xff,0x20,0x60,0x90,0x08,0x04,0x00,0x00,0x00,
//0x10,0x10,0x08,0x06,0x01,0x40,0x80,0x7f,0x00,0x00,0x01,0x06,0x0c,0x18,0x08,0x00,
//0x10,0x10,0xf0,0x1f,0x10,0xf0,0x80,0x82,0x82,0x82,0xf2,0x8a,0x86,0x82,0x80,0x00,
//0x80,0x43,0x22,0x14,0x0c,0x73,0x20,0x00,0x40,0x80,0x7f,0x00,0x00,0x00,0x00,0x00,
//0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x3f,0xc2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
//0x00,0x40,0x20,0x10,0x0c,0x03,0x00,0x00,0x01,0x06,0x0c,0x18,0x30,0x60,0x20,0x00
};
void dh(unsigned char x,unsigned char y,unsigned char n) {
unsigned char i,dd;
for (i=0;i<16;i++) {
dd=hz;
lw(x+i,y,dd);
dd=hz;
lw(x+i,y+1,dd);
}
}
main(void)
{
initial();
lcd_init();
dh(0,0,0);
//dh(18,2,4);
for(;;){};
}
页:
[1]