彙編代碼中斷MPLAB的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
如果有人知道如何發送程序計數器來進入中斷服務程序,將不勝感激。