新建 WinRAR 压缩文件.rar
(71.18 KB)
#include<pic.h>
int count=0;
interrupt CCP1INT();
display();
initCCP1();
initPORTB();
main()
{
initPORTB();
initCCP1();
while(1)
{
display();
;;
}
}
initCCP1()
{
TRISC=0x04;
T1CON=0X00;
GIE=0;
PEIE=0;
CCP1IE=0;
CCP1IF=0;
CCP1IE=1;
PEIE=1;
GIE=1;
//TMR1ON=1;
CCP1CON=0x04;
}
interrupt CCP1INT()
{
GIE=0;
CCP1IE=0;
CCP1IF=0;
//TMR1ON=0;
count++;
if(count>9) {count=0;}
//display();
CCP1IE=1;
//TMR1ON=1;
GIE=1;
}
initPORTB()
{
TRISB=0x00;
PORTB=0x00;
}
display()
{
int disp;
disp=count&0x0f;
PORTB=disp;
//PORTB=count;
}
以上为程序,具体的PROTEUS仿真工程在附件,请高手帮帮忙 |