[ATTACH=CONFIG]114651._xfImport[/ATTACH]#include<reg51.h>
unsigned char DSPL_RAM[4]={1,2,3,4};//this is for rtc data like HH MM
unsigned char code image[10]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
void main()
{
TMOD=0x01; //timer 0 in 16bit timer
TH0=0xEF;//for 4ms so refresh rate 4x4=16ms==60Hz
TL0=0xBA;
ET0=1;//enable timer 0
EA=1;//globle enable
TR0=1;//timer run
while(1)
{
//do your task for read rtc and update DSPL_RAM
}
}
void ISR() interrupt 1
{
static unsigned char i;//for digit counter
TH0=0xEF; //reload timer for next segment
TL0=0xBA;
P2|=0x0F;//OFF ALL SEGMENT
P0=image[DSPL_RAM[i]];
P2&=~(1<<i); //ON CROSPOND SEMENT
if(i++>=3)
i=0;
}