Interrupt.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /************************************************************************
  2. * ---- 居加居 ----
  3. * 文件名: Interrupt.c
  4. * 编写人员: Kinve JQ
  5. * 说明:
  6. * 版本: V0.1
  7. * 编写日期: 2018-09-30
  8. * 程序维护:
  9. * 维护记录:
  10. * 2018-09-30.Kinve:1.创建文件
  11. * 免责声明:
  12. * (c) Author Kinve JQ. All rights reserved.
  13. **************************************************************************/
  14. #include "Interrupt.h"
  15. #include "Timer.h"
  16. #include "Keys.h"
  17. uint32 sys_ms = 0;
  18. uint16 TaskTime = 0;
  19. struct bit_def Status0, Status1;
  20. /*
  21. 源 中断地址 中断号 源 中断址地 中断号
  22. 复位 0000H - SPI 中断 004BH 9
  23. 外部中断0 0003H 0 WDT 中断 0053H 10
  24. 定时器0溢出 000BH 1 ADC 中断 005BH 11
  25. 外部中断 1 0013H 2 定时器输入捕获中断 0063H 12
  26. 定时器1溢出 001BH 3 PWM 中断 006BH 13
  27. 串口 0 中断 0023H 4 故障刹车中断 0073H 14
  28. 定时器2事件 002BH 5 串口1中断 007BH 15
  29. I2C状态/超时中断 0033H 6 定时器3溢出中断 0083H 16
  30. 管脚中断 003BH 7 WKT自唤醒定时器中断 008BH 17
  31. 欠压检测中断 0043H 8
  32. */
  33. /************************************************************************************************************
  34. * TIMER 0 interrupt subroutine
  35. ************************************************************************************************************/
  36. #ifdef N76E003_IAR
  37. #pragma vector=0x0B
  38. __interrupt void Timer0_ISR ( void )
  39. #else
  40. void Timer0_ISR ( void ) interrupt 1 //interrupt address is 0x000B
  41. #endif
  42. {
  43. TH0 = HIBYTE ( Timer0_THTL );
  44. TL0 = LOBYTE ( Timer0_THTL );
  45. sys_ms += TIMER_SCAN;
  46. if ( sys_ms >= 86400000 ) //2^32 >= 24个小时
  47. {
  48. sys_ms = 0;
  49. }
  50. TaskTime += TIMER_SCAN; //0~8000
  51. if ( TaskTime % 2 == 0 )
  52. {
  53. System_Flag_2Ms = 1;
  54. }
  55. if ( TaskTime % 10 == 0 )
  56. {
  57. System_Flag_10Ms = 1;
  58. //T10MS_Count_Handler();
  59. }
  60. if ( TaskTime % 20 == 0 )
  61. {
  62. System_Flag_20Ms = 1;
  63. Keys_Even();
  64. }
  65. if ( TaskTime % 100 == 0 )
  66. {
  67. System_Flag_100Ms = 1;
  68. }
  69. if ( TaskTime % 200 == 0 )
  70. {
  71. System_Flag_200Ms = 1;
  72. }
  73. if ( TaskTime % 500 == 0 )
  74. {
  75. System_Flag_500Ms = 1;
  76. }
  77. if ( TaskTime % 1000 == 0 )
  78. {
  79. System_Flag_1s = 1;
  80. }
  81. if ( TaskTime % 5000 == 0 )
  82. {
  83. System_Flag_5s = 1;
  84. TaskTime = 0;
  85. }
  86. /*
  87. if ( BeepCounter )
  88. {
  89. if ( --BeepCounter == 0 ) StopBeep();
  90. }
  91. */
  92. }
  93. /************************************************************************************************************
  94. * TIMER 1 interrupt subroutine
  95. ************************************************************************************************************/
  96. #ifdef N76E003_IAR
  97. #pragma vector=0x1B
  98. __interrupt void Timer1_ISR ( void )
  99. #else
  100. void Timer1_ISR ( void ) interrupt 3 //interrupt address is 0x001B
  101. #endif
  102. {
  103. }
  104. /*
  105. 中断源 中断地址 中断号
  106. 复位 0000H -
  107. 外部中断0 0003H 0
  108. 定时器0溢出 000BH 1
  109. 外部中断1 0013H 2
  110. 定时器1溢出 001BH 3
  111. 串口0 中断 0023H 4
  112. 定时器2事件 002BH 5
  113. I2C状态/超时中断 0033H 6
  114. 管脚中断 003BH 7
  115. 欠压检测中断 0043H 8
  116. SPI中断 004BH 9
  117. WDT中断 0053H 10
  118. ADC中断 005BH 11
  119. 定时器输入捕获中断 0063H 12
  120. PWM中断 006BH 13
  121. 故障刹车中断 0073H 14
  122. 串口1中断 007BH 15
  123. 定时器3溢出中断 0083H 16
  124. WKT自唤醒定时器中断 008BH 17
  125. */
  126. /*************** (C) COPYRIGHT Kinve JQ *******END OF FILE **************/