[DemoCode下载] 各种单片机中断程序的写法

[复制链接]
1170|1
 楼主| Mancherstun 发表于 2016-2-29 15:49 | 显示全部楼层 |阅读模式
  1. ////////////////////    下面是PIC单片机中断的写法!///////////////////////////////////////////////////////////

  2. #include<pic.h>
  3. __CONFIG(0x1832); //写配置位
  4. volatile char i; //中断用到的变量须要用volatile修饰一下

  5. void main()
  6. {

  7. }

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

  10. }

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

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

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

  19. SIGNAL(SIG_INTERRUPT0) //外部中断0
  20. {

  21. }
  22. SIGNAL(SIG__INTERRUPT1) //外部中断1
  23. {

  24. }
  25. SIGNAL(SIG_OVERFLOW1) //定时器1溢出中断
  26. {

  27. }

  28. SIGNAL(SIG_ADC)//ADC中断的

  29. {

  30. }

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

  32. #include<iom16v.h>
  33. volatile char i; //中断用到的变量须要用volatile修饰一下
  34. #pragma interrupt_handler miao:9
  35. #pragma data:code
  36. const  table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d, 0x07,
  37.              0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};

  38. void main()
  39. {
  40.    SREG|=(1<<7); //开总中断
  41. }

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

  44. }


dentsgot 发表于 2016-3-3 22:26 | 显示全部楼层
好像没有写新唐单片机的中断写法呢
您需要登录后才可以回帖 登录 | 注册

本版积分规则

35

主题

294

帖子

2

粉丝
快速回复 在线客服 返回列表 返回顶部