NXP

Lpc系列ARM的中断向量表中实现方式

2019-07-12 13:20发布

         实现方式有两种:第一种 0x18处放置        在发生中断时   跳到VICVectAddr中的地址处 代码如下         EXTERN undef_handler, prefetch_handler, data_handler, fiq_handler
        ARM
__vector:
        ;;
        ldr   pc,[pc,#+24]              ;; Reset
        ldr   pc,[pc,#+24]              ;; Undefined instructions
        B   .                           ;; Software interrupt (SWI/SVC)
        ldr   pc,[pc,#+24]              ;; Prefetch abort
        ldr   pc,[pc,#+24]              ;; Data abort
__vector_0x14:
        DC32  0                         ;; RESERVED
        ldr   pc,[pc,#-0xFF0]           ;; IRQ
        ldr   pc,[pc,#+24]              ;; FIQ
        DC32  __iar_program_start       ;; Reset
        DC32  undef_handler             ;; Undefined instructions
        DC32  0                         ;; Software interrupt (SWI/SVC)
        DC32  prefetch_handler          ;; Prefetch abort
        DC32  data_handler              ;; Data abort
        DC32  0                         ;; RESERVED
        DC32  0                         ;; IRQ
        DC32  fiq_handler               ;; FIQ
第二种   这种方式也可以称为万能的中断方式 可以用于任何一种ARM 程序先跳到一个C语言编写的函数中 然后在这个函数里找到中断服务程序的地址(找中断服务程序地址的方法会因芯片的不同而不同)  EXTERN IRQ_Handler         ARM
__vector:
        ;;
        ldr   pc,[pc,#+24]              ;; Reset
        B   .                           ;; Undefined instructions
        B   .                           ;; Software interrupt (SWI/SVC)
        B   .                           ;; Prefetch abort
        B   .                           ;; Data abort
__vector_0x14:
        DC32  0                         ;; RESERVED
        ldr   pc,[pc,#+24]              ;; IRQ
        ldr   pc,[pc,#+24]              ;; FIQ
        DC32  __iar_program_start       ;; Reset
        DC32  0                         ;; Undefined instructions
        DC32  0                         ;; Software interrupt (SWI/SVC)
        DC32  0                         ;; Prefetch abort
        DC32  0                         ;; Data abort
        DC32  0                         ;; RESERVED
        DC32  IRQ_Handler               ;; IRQ
  这种是跳到C函数IRQ_Handler中,IRQ_Handler 的代码如下,其功能也是取出 VICVectAddr中的地址进行执行 __irq __arm void IRQ_Handler(void)
{
  void (*interrupt_function)();
  unsigned int vector;
  vector = VICVectAddr;   // 取得中断服务程序地址
  interrupt_function = (void(*)())vector;
  (*interrupt_function)();  // Call vectored interrupt function.
  VICVectAddr = 0;        // 清除中断
}