| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1400 人关注过本帖
标题:大佬们能不能帮我看一下怎么加中断?
只看楼主 加入收藏
尘曦
Rank: 2
来 自:四川省泸州市
等 级:论坛游民
帖 子:14
专家分:20
注 册:2018-10-28
收藏
 问题点数:0 回复次数:0 
大佬们能不能帮我看一下怎么加中断?
//加按键实现秒表的暂停,继续。我试着加了,要么不动,要么没用。求解//
#include "reg52.h"
#define ucher unsigned char
#define uint unsigned  int                                                                        
typedef unsigned char u8;                                                   

sbit LCD_RW=P2^5;
sbit LCD_RS=P2^6;
sbit LCD_E=P2^7;
ucher count;fen;miao;hao;
u8   disp[]="11                       ";
ucher code disp1[]="    00:00:0";

void delay(uint c) //1ms  
{
    uint a,b;
    for (a=0; a<c; a++)
        for (b=0; b<124; b++);            
}
//void delay(uint i)  //1us
//{
//    while(i--);
//}

void lcdwrite_com(ucher com)
{
    LCD_E=0;
    LCD_RS=0;
    LCD_RW=0;

    LCD_DATAPINS=com;
    delay(5);

    LCD_E=1;
    delay(5);
    LCD_E=0;

}
void lcdwrite_date(ucher date)
{
    LCD_E=0;
    LCD_RS=1;
    LCD_RW=0;

    LCD_DATAPINS=date;
    delay(5);

    LCD_E=1;
    delay(5);
    LCD_E=0;


}
void init()
{   
    fen=00;
    miao=00;
    hao=00;
    lcdwrite_com(0x38);
    lcdwrite_com(0x38);
    lcdwrite_com(0x38);
    lcdwrite_com(0x0c);
    lcdwrite_com(0x06);
    lcdwrite_com(0x01);
    {
    ucher num;
    lcdwrite_com(0x00+0x80);
    for(num=0;num<16;num++)
        {
        lcdwrite_date(disp[num]);
        }
    lcdwrite_com(0x80+0x40);
    for(num=0;num<11;num++)
        {
        lcdwrite_date(disp1[num]);            
        }
    TMOD=0x01;
    TH0=(65536-50000)/256;
    TL0=(65536-50000)%256;
    EA=1;
    ET0=1;
    TR0=1;
}
//void dis()
//{
//    ucher num;
//    lcdwrite_com(0x00+0x80);
//    for(num=0;num<16;num++)
//        {
//        lcdwrite_date(disp[num]);
//        }
//    lcdwrite_com(0x80+0x40);
//    for(num=0;num<16;num++)
//        {
//        lcdwrite_date(disp1[num]);            
//        }
}




//    lcdwrite_com(0x07);                                //每写一个数据屏幕就要右移一位,就相对于数据来说就是左移了;
//    while(1)
//    {   
//        lcdwrite_com(0x00+0x80);
//        for(num=0;num<12;num++)
//        {
//            lcdwrite_date(disp[num]);
//            delay(500);    //如果不加这条延时语句的话滚动会非常快。
//        }
void lcdwrite_fmh1(ucher add,ucher date)
{
    ucher h;
    h=date%10;
    lcdwrite_com(0x80+0x40+add);
    lcdwrite_date(0x30+h);
}
//void lcdwrite_fmh2(ucher add,ucher date)
//{
//    ucher i;
//    i=date%1000;
//    lcdwrite_com(0x80+0x40+add);
//    lcdwrite_date(0x30+i);
//}
void lcdwrite_fmh(ucher add,ucher date)
{
    ucher s,g;
    s=date/10;
    g=date%10;
    lcdwrite_com(0x80+0x40+add);
    lcdwrite_date(0x30+s);
    lcdwrite_date(0x30+g);        
}         
void main()
{
    init();
    while(1)
    {
        if(count==2)
        {
            count=0;
            hao++;
            if(hao==10)
            {
                hao=0;
                miao++;
                if(miao==60)
                {
                    miao=0;
                    fen++;
                    if(fen==60)
                    {
                        fen=0;     
                    }
                    lcdwrite_fmh(4,fen);   
                }
                lcdwrite_fmh(7,miao);
            }
            lcdwrite_fmh1(10,hao);               
        }

//    while(1)
//    {
//        dis();
//    }
    }
}

void timer0() interrupt 1
{
    TH0=(65536-50000)/256;
    TL0=(65536-50000)%256;
    count++;   
}
搜索更多相关主题的帖子: void delay for date num 
2018-12-05 22:41
快速回复:大佬们能不能帮我看一下怎么加中断?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017536 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved