各种单片机中断程序的写法

嵌入式系统 时间:2016-12-02来源:网络
//////////////////// 下面是PIC单片机中断的写法!///////////////////////////////////////////////////////////

#include
__CONFIG(0x1832); //写配置位
volatile char i; //中断用到的变量须要用volatile修饰一下

void main()
{

}

void interrupt tt() //中断服务程序,不用申明
{

}

////////////////////////////////////////// 下面AVR单片机GCC中断程序的写法 /////////////////////////////////////////////

#include<avr/io.h>
#include
volatile char i; //中断用到的变量须要用volatile修饰一下

int main(void) //GCC编写的主函数是要用int型的函数
{
sei(); //开总中断
}

SIGNAL(SIG_INTERRUPT0) //外部中断0
{

}
SIGNAL(SIG__INTERRUPT1) //外部中断1
{

}
SIGNAL(SIG_OVERFLOW1) //定时器1溢出中断
{

}

SIGNAL(SIG_ADC)//ADC中断的

{

}

/////////////////////////////////// 下面是AVR单片机的ICC中断程序写法!///////////////////////////////////////////////////

#include
volatile char i; //中断用到的变量须要用volatile修饰一下
#pragma interrupt_handler miao:9
#pragmadata:code
const table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d, 0x07,
0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};

void main()
{
SREG|=(1<<7); //开总中断
}

void miao() //中断服务程序
{

}

关键词: 单片机中断程

加入微信
获取电子行业最新资讯
搜索微信公众号:EEPW

或用微信扫描左侧二维码

相关文章

查看电脑版