chuong trinh dem 00-59 dung T/C
// chuong trinh dem 00-59 dung T/C
//---------------------------------
#include"16f877a.h"
#include"def_877a.h"
#use delay(clock=4000000)
const int ma_7doan[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
int biengiay=0,bientran,chuc,don_vi,chuc_7doan,don_vi_7doan;
// khai bao ngat ngoai
#int_timer1
void ngat_timer()
{
bientran++;
if (bientran==20)
{
bientran=0;
biengiay++;
if(biengiay==60) biengiay=0;
}
}
//chuong trinh con hien thi tren led 7 doan
void hien_thi()
{
portc=chuc_7doan;
rd0=0;
delay_us(100);
rd0=1;
portc=don_vi_7doan;
rd1=0;
delay_us(100);
rd1=1;
}
//chuong trinh chinh
void main()
{
//dinh nghia cac dau vao ra
trisc=0;
trisd0=0;
trisd1=0;
//khai bao cho phep ngat
enable_interrupts(int_timer1);
enable_interrupts(global);
setup_timer_1(T1_internal|T1_div_by_1);
while(true)
{
chuc=biengiay/10;
don_vi=biengiay%10;
chuc_7doan=ma_7doan[chuc];
don_vi_7doan=ma_7doan[don_vi];
hien_thi();
}
}
Bạn đang đọc truyện trên: Truyen247.Pro