芯片PIC16F676,编译器picc
程序如下:
进不了中断哦,哪个大侠指点一下,谢谢
#include<pic.h>
__CONFIG (UNPROTECT & BORDIS & MCLRDIS & PWRTDIS & WDTDIS & INTOSCIO);
#define uchar unsigned char
#define uint unsigned int
#define LED1 (RC1)
#define LED1_ON (RC1 = 1)
#define LED1_OFF (RC1 = 0)
#define LED2_ON (RC2 = 1)
#define LED2_OFF (RC2 = 0)
#define LED2 (RC2)
#define RF_CE_HIGH (RC4 = 1)
#define RF_CE_LOW (RC4 = 0)
#define RF_DIN (RC5)
/*************************************************/
uchar Timer0Cnt = 0;
uchar FLAG1 = 0;
void Dlms(uint z);
void Timer1Init(void);
void Port_init(void);
void WatchDogInit(void);
void Timer0Init(void);
void Port_init(void)
{
ANSEL=0x00; //0 = Digital I/O. Pin is assigned to port or special function.
CMCON=0x07; //CM2:CM0 = 111 Comparator Off (Lowest power)
TRISA=0x00; //RA2(P32) INPUT
PORTA=0xff;
TRISC=0x21; //RC0 RC5 as input Other as output
LED1_OFF;
LED2_OFF;
}
/**************************************************/
void Timer1Init(void)
{
//MR1GE = 0;
TMR1L = 0x00;
TMR1H = 0x00;
T1CON = 0x04;
//TMR1IE = 1;
//PEIE = 1;
//GIE = 1;
//TMR1ON = 1;
}
void interrupt ISR(void)
{
/*
if (TMR1IE && TMR1IF)
{
TMR1IF = 0; //清除TMR1 中断标志
}*/
if(T0IE & T0IF)
{
T0IF = 0;
Timer0Cnt++;
if(Timer0Cnt == 3)
{
Timer0Cnt = 0;
FLAG1 = 1;
LED1 = !LED1;
}
}
}
void WatchDogInit(void)
{
CLRWDT();
TMR0 = 0;
OPTION = 0x2F;
CLRWDT();
OPTION = 0x2D;
}
void Timer0Init(void)
{
CLRWDT();
OPTION = 0x07; // intclk 1:256
TMR0 = 0x00;
T0IE = 1;
PEIE = 1;
GIE = 1;
}
/**************************************************
Function: Dlms(uint z);
Description:
delay zms
/**************************************************/
void Dlms(uint z){
uint i,a;
for(a=z;a>0;a--)
for(i=110;i>0;i--);
}
/**************************************************/
/**************************************************
Function: main();
Description:
control all subprogrammes;
/**************************************************/
void main(void)
{
OSCCAL = _READ_OSCCAL_DATA();
Port_init();
Timer1Init();
Timer0Init();
FLAG1 = 0;
//Dlms(15); //delay for 15ms let nrf24L01 POR reliably
while(1)
{
} |