em nho may anh giúp dùm vì sắp nộp đồ án rồi.tình hình là em có dặt làm mach ma em khong hiểu ý nghĩa các lệnh.nhờ mấy anh giải thích dùm.vì em hoc mplab nhung code này viết c em k hiểu
#include <16F877A.h>
#include <def_877a.h>
#FUSES NOWDT, HS, NOPUT, NOPROTECT, NODEBUG, NOBROWNOUT, NOLVP, NOCPD, NOWRT
#use delay(clock=20000000)
#define mode RA0
#define dwn RA1
#define up RA2
//khai bao bien
int16 count=0;
int8 sodem=0;
//int8 chuc,dvi;
const unsigned char dig[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x9 0};
//chuong trinh con
#INT_TIMER1 //khai bao ngat de dinh thoi gian
VOID NGAT_TIMER1()
{
SET_TIMER1(15536);
count++;
IF(count==100) //20*50000us = 1000000us = 1s
{
sodem++;
count=0;
}
}
void hienthi()
{
int j =0;
while(j<5)
{
portb=dig[sodem/10];
portd = 0x7f;
delay_us(100);
portd = 0xff;
portb=dig[sodem%10];
portd = 0xbf;
delay_us(100);
portd = 0xff;
portc = 0xff;
j++;
}
}
//chuong trinh chinh
void main()
{
trisa = 0xff; // khai bao cac port deu la ngo ra
trisb = 0x00;
trisd = 0x00;
set_tris_c(0);
SETUP_TIMER_1(T1_INTERNAL); //cho phep cac ngat hoat dong de dem thoi gian
ENABLE_INTERRUPTS(GLOBAL);
ENABLE_INTERRUPTS(INT_TIMER1);
SET_TIMER1(15536); //T_dinhthoi = (65536-15536)*1us = 50000us
while(true)
{
hienthi();
if(sodem>99) sodem=0;
}
}
mấy anh giúp dùm em nhe em càm ơn.
|