大佬们能不能帮我看一下怎么加中断?
//加按键实现秒表的暂停,继续。我试着加了,要么不动,要么没用。求解//#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++;
}