英锐恩单片机论坛,Microchip单片机,模拟器件,接口电路,麦肯单片机,单片机应用交流

 找回密码
 立即注册
搜索
电子烟方案单片机单片机开发深圳单片机开发
单片机方案国产单片机8位单片机电子烟方案开发
查看: 4304|回复: 1
打印 上一主题 下一主题

编译的问题

[复制链接]
跳转到指定楼层
1#
发表于 2009-4-14 14:36:59 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 winnie 于 2009-4-14 14:38 编辑

# include <pic1674.h>;
# include <stdio.h>;
# define  CS2  RB4 ; 为什么这样不能定义字节???????????
# define  D_I  RB0 ;
# define  R_W  RB1 ;
# define  CS1  RB3 ;
  char buf[20];
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[i+n*32];
        lw(x+i,y,dd);
        dd=hz[i+n*32+16];
        lw(x+i,y+1,dd);
    }
}
main(void)
{
initial();
lcd_init();
dh(0,0,0);
//dh(18,2,4);
for(;;){};
}
2#
 楼主| 发表于 2009-4-14 14:39:58 | 只看该作者
改如下:
# include <pic1674.h>
# include <stdio.h>
# define  CS2  RB4
# define  D_I  RB0
# define  R_W  RB1
# define  CS1  RB3
  char buf[20];
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[i+n*32];
        lw(x+i,y,dd);
        dd=hz[i+n*32+16];
        lw(x+i,y+1,dd);
    }
}

main(void)
{
initial();
lcd_init();
dh(0,0,0);
//dh(18,2,4);
for(;;){};
}
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|公司首页|Microchip单片机,模拟器件,接口电路,麦肯单片机,单片机应用交流 ( 粤ICP备09008620号 )

GMT+8, 2024-12-26 09:07 , Processed in 0.061664 second(s), 22 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表