1481 views|0 replies

2015

Posts

0

Resources
The OP
 

External interrupt and time interrupt count 0-999 displayed on the digital tube example [Copy link]

51 routines

#include<reg51.h>
typedef unsigned char uchar; xdata uchar
LED_CS _at_ 0x9000
;
xdata uchar LED_OUTSEG _at_ 0x9004
; char LEDMAP[]={ //Eight-segment tube display code 0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71 }; code unsigned char LEDWED []= {0x20,0x10,0x08,0x04,0x02,0x01}; //Display buffer uchar led_buf[]={0,0,0}; void delay(unsigned char ms) { unsigned char i; while(ms--) { for(i = 0; i < 50; i++); } } void ADcal() { led_buf[0]=Count/100;//hundreds digit led_buf[1]=Count/10%10;//tens digit led_buf [2]=Count%10; } //Open time interrupt void initTime(){ IE=0x83; TR0=1; } //Open external interrupt void initOut(){ IE=0x83; IT0=1; } void timer0( ) interrupt 1 { TH0=(65535-50000)/256; TL0=(65535-50000)%256; n++; if(n==2) { P10=1; delay(20); P10=0; delay(20); Count++; if(Count>=999) { Count= 0; } } } void out0() interrupt 0 { Count++; if(Count>=999) { Count=0; } } void main() { unsigned int i=0; initOut(); //Turn on external interrupt' initTime (); TH0=(65535-50000)/256; TL0=(65535-50000)%256; delay(10); while(1) { ADcal(); LED_CS=0; if(i==0) { LED_OUTSEG =LEDMAP[led_buf











































































];
}
if(i==1)
{
LED_OUTSEG=LEDMAP[led_buf
];
}
if(i==2)
{
LED_OUTSEG=LEDMAP[led_buf
];
}
LED_OUTBIT=LEDWED
;
i++;
i=i%3;
delay(10);

}
}

This post is from Microcontroller MCU
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list