⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 intr.c

📁 pic单片机例程
💻 C
字号:
#include	<htc.h>

/*
 *	Interrupt test for PIC 
 *
 *	Copyright (C)1997 HI-TECH Software.
 *	Freely distributable.
 */

static volatile long	count;
static volatile bit	bad_intr;

void
main(void)
{
	/* setup stuff */

	T0CS = 0;		// Timer increments on instruction clock
	TRISB = 0xFE;		// Port B 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
	PORTB ^= 1;		// toggle bit 0 of Port B, to show we're alive
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -