|
发表于 2010-9-21 06:43:07
|
显示全部楼层
I ran the following code:
========code=========
#include <htc.h>
//#include "Main_heard.h"
#include "gpio.h"
__CONFIG(BORDIS & MCLRDIS & PWRTDIS & WDTDIS & HS & LVPDIS);
__CONFIG(IESODIS & FCMDIS & DEBUGDIS & BORV21);
#define LED_PORT PORTC //led indicators on portc
#define LED_DDR TRISC
#define LED_TMR0 (1<<0) //flip'd if tmr0 interrupt is serviced
#define LED_TMR1 (1<<1) //flip'd if tmr1 interrupt is serviced
#define LED_TMR2 (1<<2) //flip'd if tmr2 interrupt is serviced
void main(void) {
ANSEL=0x00; //all pins gpio
ANSELH=0x00;
IRCF2=1, IRCF1=1, IRCF0=0; //running at 4mhz
//T0IF=0;
T0IE=1;//open int need alawys open
PSA=0; PS1=0; PS0=0;
T0CS=0;
TMR0=0;
PEIE=1;
GIE=1;
IO_CLR(LED_PORT, LED_TMR0 | LED_TMR1 | LED_TMR2); //led_tmr0/1/2 driven to low
IO_OUT(LED_DDR, LED_TMR0 | LED_TMR1 | LED_TMR2); //led_tmr0/1/2 as output
while(1)
continue;
}
/****************ISR******************************/
static void interrupt ISR(void) // Here be interrupt function - the name is unimportant.
{
if (T0IE&T0IF)// SYSTEMTICK 4.096MS int need scan led an count or decount
{T0IF=0;
IO_FLP(LED_PORT, LED_TMR0); //flip led_tmr0
}
if (RBIE&RBIF)//partB int need scan key
{RBIF=0;
}
if (TMR1IE&TMR1IF)//ccp INT read perid
{TMR1IF=0;
IO_FLP(LED_PORT, LED_TMR1); //flip led_tmr1
}
if (TMR2IE&TMR2IF)// PWM TIME INT CHANGE DUTY
{TMR2IE=0; //should reset the flag, not the interrupt enabling bit
IO_FLP(LED_PORT, LED_TMR2); //flip led_tmr2
}
}
==========end code=============
it has three indicators, portc.0, portc.1, and portc.2 (on a 16F886), designated as tmr0/1/2 interrupt indicators: when tmr0 interrupt is serviced, LED_TMR0 (portc.0) is flip'd, and so on and so forth.
when I ran the code, the only thing flip'd is portc.0 (=LED_TMR0). that means the only interrupt service being executed is the one related to T0IF, as expected. |
|