阅读:628回复:0
新手∶用c写了一计数的程序在实验板上,但是出了点小问题,不知该如何解决
#include "reg52.h"
char code LEDCODE[]={0x3f,0x6,0x5b,0x4f,0x66,0x6d,0x7d,0x7,0x7f,0x6f}; unsigned char Disbuff[6] , Ledp=0; sbit Bell=P3^7; void timer (void) interrupt 1 { P2=P2&0xc0; P2=P2|1<<Ledp; P0=LEDCODE[Disbuff][Ledp]]; Ledp=(Ledp+1)%6; } void Delay (void) { unsigned int i; for(i=0;i<30000;i++) ; } void main (void) { unsigned int i; TMOD=0X01; TR0=1; ET0=1; EA=1; TL0=(65535-200)%256; TH0=(65535-200)/256; while (1) { Delay(); Bell=~Bell; Disbuff[0]=(Disbuff[0]+1)%10; for (i=1; i<6; i++) { if(!Disbuff[i-1]) Disbuff=(Disbuff+1)%10; else break; } } } 数码管的灯会闪,其他基本正常。 小弟我不怎么会用中断。 |
|