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

 找回密码
 立即注册
搜索
电子烟方案单片机单片机开发深圳单片机开发
单片机方案国产单片机8位单片机电子烟方案开发
查看: 3030|回复: 0
打印 上一主题 下一主题

picc的中断函数

[复制链接]
跳转到指定楼层
1#
发表于 2009-5-22 17:54:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
#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
}
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|公司首页|Microchip单片机,模拟器件,接口电路,麦肯单片机,单片机应用交流 ( 粤ICP备09008620号 )

GMT+8, 2024-4-19 17:15 , Processed in 0.051994 second(s), 22 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表