打印

1602液晶程序

[复制链接]
2428|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
wo198492|  楼主 | 2009-4-26 19:50 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
ξπωπ 19:07:21
这是我的程序. 1602液晶PIC  16F877A PICC 编的
ξπωπ 19:07:25
#include<pic.h>
#define rs RA1
#define rw RA2
#define e  RA3
#define uchar unsigned char
#define uint  unsigned  int
char miao,shi,fen;
uchar num;
uchar count,s1num,add;

const uchar mingzi[]=" 2009-04-22 CMU ";
 const uchar sijian[]="    00:00:00";
void delay(uint z)
{
    uint x,y;
    for(x=z;x>0;x--)
        for(y=110;y>0;y--);
}
void write_com(uchar com)//写指令
{
    rs=0;
    rw=0;
    PORTC=com;
    delay(5);
    e=1;
    delay(5);
    e=0;
}
void write_date(uchar date)//写数据
{
    rs=1;
    rw=0;
    PORTC=date;
    delay(5);
    e=1;
    delay(5);
    e=0;
}
void init()//初始化
{

    ADCON1=0X07;
    TRISA=0x00;
    TRISC=0x00;
    write_com(0x01);
    write_com(0x38);
   write_com(0x0e);
    write_com(0x06);   
    write_com(0x80);
        for(num=0;num<12;num++)
        {
            write_date(mingzi[num]);
            delay(5);
        }
     write_com(0x80+0x40);
        for(num=0;num<12;num++)
        {
            write_date(sijian[num]);
            delay(5);
        }
   e=0;
   OPTION=0X03;
   TMR0=0X00;
   INTCON=0Xa0;        
}
void write_sfm(uchar add,uchar date)
{
    uchar shi,ge;
    shi=date/10;
    ge=date%10;
    write_com(0x80+0x40+add);
    write_date(0x30+shi);
    write_date(0x30+ge);
}

void main()
{
init();
while(1);
}
//**************TMR0中断数码管扫描程序*********************
void interrupt tmr0(void)
{         
if(T0IE && T0IF)    
{    
  T0IF=0;   //清除中断标志位
  {
      TMR0=0;
      count++;
if(count==18)
        {
            count=0;
            miao++;
            if(miao==60)
            {
                miao=0;
                fen++;
                    fen=0;
                    shi++;
                    if(shi==24)
                    {
                        shi=0;
                    }
                    write_sfm(4,shi);
                }
                write_sfm(7,fen);
            }
            write_sfm(10,miao);
            
        }    
}
}
ξπωπ 19:16:08
我试过 只显示可以. 加上中断就不行了.下面是提示  .........................................................



清除: 正在删除中间文件和输出文件.
清除: 删除的文件 "E:x.mcs".
清除: 完成.
Executing: "C:Program FilesHI-TECH SoftwarePICC9.50BINPICC.EXE" -C -E"lcdxiaoshi.cce" "lcdxiaoshi.c" -O"lcdxiaoshi.obj" -Zg9 -O -ASMLIST -Q -MPLAB -16F877A
Advisory[1207]   : some of the command line options you are using are now obsolete
Advisory[1208]   : use --help option or refer to the user manual for option details
Warning[349] E:lcdxiaoshi.c 40 : non-prototyped function declaration for "init"
Executing: "C:Program FilesHI-TECH SoftwarePICC9.50BINPICC.EXE" -E"x.lde" "E:lcdxiaoshi.obj" -M"x.map" -O"x.cof" -O"x.hex" -Q -MPLAB -16F877A
Advisory[1207]   : some of the command line options you are using are now obsolete
Advisory[1208]   : use --help option or refer to the user manual for option details
Error[472]   : non-reentrant function "_write_com" appears in multiple call graphs: rooted at "_tmr0" and "_main"
Error[472]   : non-reentrant function "_delay" appears in multiple call graphs: rooted at "_tmr0" and "_main"
Error[472]   : non-reentrant function "_delay" appears in multiple call graphs: rooted at "_tmr0" and "_main"
Error[472]   : non-reentrant function "_write_date" appears in multiple call graphs: rooted at "_tmr0" and "_main"
BUILD FAILED: 
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

15

主题

24

帖子

0

粉丝