英锐恩单片机论坛,Microchip单片机,模拟器件,接口电路,麦肯单片机,单片机应用交流
标题:
Timer1的定时中断程序
[打印本页]
作者:
winnie
时间:
2009-3-31 14:32
标题:
Timer1的定时中断程序
#include<pic.h>
volatile unsigned char counter;
void interrupt timer1(void)
{
if(TMR1IE&&TMR1IF==1)
{
TMR1IF=0;
counter ++;
if(counter==0x08)
{
counter=0;
RC0=0;
TMR1IE=0;
}
TMR1H=0x3C;
TMR1L=0xb0;
}
}
void main()
{
TRISC0=0;
TRISC1=0;
counter=0;
RC0=1;
RC1=0;
TMR1CS=0;
TMR1H=0x3c;
TMR1L=0xb0;
TMR1IF=0;
TMR1IE=1;
TMR1ON=1;
INTCON=0XC0; //
while(1)
{
RC0=0;
if(TMR1IE==0) break;
}
while(1)
{;}
}
欢迎光临 英锐恩单片机论坛,Microchip单片机,模拟器件,接口电路,麦肯单片机,单片机应用交流 (http://enroobbs.com/)
Powered by Discuz! X3.2