请教那位高手帮我看看错在哪里??? 代码如下:
#include <reg51.h> unsigned int temp=0; bit pf2=0; sbit P2_3=P2^3; sbit P2_2=P2^2; sbit P2_1=P2^1; sbit P2_0=P2^0; sbit P3_2=P3^2; sbit P3_3=P3^3; //中断子程序*********************************************** viod wai_zhong_duan_1() interrupt 2 using 2 { pf2=~pf2; } //延时子程序******************************************** void delayms(unsigned char ms) { unsigned char i; while(ms--) { for(i = 0; i <120; i++); } }
//显示子程序********************************************* void display() { unsigned char seg[10]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90}; unsigned char qing,bai,shi,ge; int i; i=temp; qing=i/1000; i=i-(qing*1000); bai=i/100; i=i-(bai*100); shi=i/10; i=i-(shi*10); ge=i; for(i=1;i<=50;i++) { P2_0=0; P0=seg[qing]; delayms(1); P2_0=1; P2_1=0; P0=seg[bai]; delayms(1); P2_1=1; P2_2=0; P0=seg[shi]; delayms(1); P2_2=1; P2_3=0; P0=seg[ge]; delayms(1); P2_3=1; } }
//主程序*************************************************** main() { IE=0x84; P3=0xff; IT0=0; pf2=0; while(1) { display(); if(pf2==1) temp++; if(temp==10000) temp=0; if(P3_3==0) temp=0; } }
|