#include<pic.h>
#define uchar unsigned char
#define uint unsigned int
__CONFIG(0x3B31);
#define S17 RC7 //定义按键IO
#define S18 RC6
#define S19 RC5
#define S20 RC4
#define S21 RC3
void init();
uint intnum;
void main()
{
init();
while(1)
{
if(S17==0)
{
if(intnum>20)
{
if(S17==0)
//intnum=0;
RB2=!RB2;
}
}
}
}
void init()
{
TRISD=0;
PORTD=0XFF;
TRISC=0x00; //RC设置为输出
PORTC=0xff; //初始化为高
TRISB=0x00; //RB设置为输出
PORTB=0xff; //初始化为高
INTCON=0xc0;
PIE1=0x01;
TMR1L=(65536-50000)%256;
TMR1H=(65536-50000)/256;
T1CON=0x21;
}
void interrupt time0()
{
TMR1IF=0;
TMR1L=(65536-50000)%256;
TMR1H=(65536-50000)/256;
intnum++;
//RD0=!RD0;//
}
|