英锐恩单片机论坛,Microchip单片机,模拟器件,接口电路,麦肯单片机,单片机应用交流

标题: picc的中断函数 [打印本页]

作者: winnie    时间: 2009-5-22 17:54
标题: picc的中断函数
#include <pic.h>
/*
* Interrupt test for PIC
*
* Copyright (C)1997 HI-TECH Software.
* Freely distributable.
*/
static long count;
static bit bad_intr;
void
main(void)
{
/* setup stuff */
#ifdef _16C71
ADCON1 = 3;  // 16C71 requires Port A reconfiguration
#endif
T0CS = 0;  // Timer increments on instruction clock
TRISA = 0xFE;  // Port A bit 0 is output
T0IE = 1;  // Enable interrupt on TMR0 overflow
GIE = 1;  // Global interrupt enable
for(;;)
  CLRWDT(); // Idly kick the dog
}
static void interrupt
isr(void)   // Here be interrupt function - the name is
    // unimportant.
{
if(!T0IF)  // Was this a timer overflow?
  bad_intr = 1; // NO! Shock horror!
count++;  // Add 1 to count - insert idle comment
T0IF = 0;  // Clear interrupt flag, ready for next
PORTA ^= 1;  // toggle bit 0 of Port A, to show we're alive
}




欢迎光临 英锐恩单片机论坛,Microchip单片机,模拟器件,接口电路,麦肯单片机,单片机应用交流 (http://enroobbs.com/) Powered by Discuz! X3.2