【发布时间】:2015-02-09 20:59:50
【问题描述】:
MPlab 中的汇编代码中断
MPLAB IDE:v8.92 芯片:dsPIC33FJ64GP802
我一直在查看这段代码以获取汇编语言的中断。我不确定代码或链接器文件是否有问题(我已经使用了芯片的链接器和头文件)但是当我触发异步切换 INT0 时,代码会遇到
CORE-W0008: Software Reset Instruction called at PC=0x000202
并且代码从第一行继续,而不是进入中断子程序。 我的研究并没有为这个软件重置指令找到很多有用的结果。
这里是代码;
.include "p33FJ64GP802.inc"
.global __reset
.global __INT0interrupt ; ISR (Interrupt Service Routine)
.text
__reset: ; Code section
MOV #0x900, W15 ; Enable the stack register
MOV #__SPLIM_init, W0
MOV W0, SPLIM ; Initialize Stack Pointer Limit Register
NOP
CALL INITinit ; Initialize interrupt enables
CALL initIO ; Initialize interrupt I/O ports
CALL LED1
INITinit: ; Initialize the interrupt
BSET IPC0, #0 ; Set Interrupt Priority Control bit #0 high
BSET IPC0, #1 ; " " " " bit #1 high
BSET IPC0, #2 ; " " " " bit #2 high
(interrupt has highest priority)
BSET IEC0, #0 ; Set Interrupt Enable Control (Register 0) High
(Interrupt request enabled)
BCLR IFS0, #0 ; Clear Interrupt Flag Status (Register 0) Low
RETURN
initIO: ; Initialize Input/Output
MOV #0XFFFF, W0
MOV W0, AD1PCFGL ; Disable analog I/O
MOV #0x0000, W0
MOV W0, TRISB ; Output direction
NOP
BCLR TRISB, #1 ; Bit #1 cleared 'low' in TRISB | Pin RB1 is
output for LED1
NOP
BCLR TRISB, #2 ; Bit #2 cleared 'low' in TRISB | Pin RB2 is
output for LED2
NOP
BSET TRISB, #7 ; Bit #7 set 'high' in TRISB | Pin RB7 is
input for interupt
NOP
RETURN
LED1: ; Start of function 'LED 1'
MOV #0xFFFF, W1 ; Blue LED 1 On
MOV W1, PORTB
CALL DELAY
MOV #0x0000, W1 ; Blue LED 1 Off
MOV W1, PORTB
CALL DELAY
GOTO LED1 ; Go to LED1
DELAY: ; Start function delay
MOV #0x0001, W2 ; Set W2 High
MOV #0x0000, W3 ; Start W3 Low
again0: ; Function 'again1'
ADD #0x0001, W3 ; Add value '1' to regiter 3
CPSEQ W3, W2 ; Compare W3 to W2- if equal then skip next line
goto again0 ; Go to again1
RETURN ; Return from subroutine
__INT0interrupt: ; ISR
NOP ; No operation
BTG PORTB, #7 ; BIT #7 of Port B is toggled(complimented)
MOV #0x0005, W4
MOV #0X0000, W5
again1:
MOV #0XFFFF, W1
MOV W1, PORTB ; Red LED 2 On
CALL DELAY
MOV #0X0000, W1
MOV W1, PORTB ; Red LED 2 OFF
CALL DELAY
INC W5, W5
CPSEQ W4, W5
goto again1
BCLR IFS0, #0 ; BIT #0 of the IFSO is cleared
NOP
RETFIE ; Return from interupt enable
.end
如果有人知道如何发送程序计数器进入中断服务程序,将不胜感激。
【问题讨论】: