PIC單片機(jī)定時(shí)器2的使用方法
#include #define uchar unsigned char void init() void interrupt time0()
#define uint unsigned int
__CONFIG(0x3B31);
void init();
uint intnum;
void main()
{
init();
while(1)
{
if(intnum==5000)
{
intnum=0;
RD0=!RD0;
}
}
}
{
TRISD=0;
PORTD=0;
INTCON=0xc0;
PIE1=0x02;
TMR2=0;
PR2=100;
T2CON=0x0D;
}
{
TMR2IF=0;
//TMR2=56;
//RD0=!RD0;//
intnum++;
}