Hi, i'm trying to make a program that when i put VCC on one pin of the PortA, the program jump to an Interrupt and turns on a Led on Port B.
The problem is that i can't configure the interrups, and i can't find my error, can anyone help me?? Thanks
it's a simply test program, here it's:
; Include derivative-specific definitions
INCLUDE 'derivative.inc'
; export symbols
;
XDEF _Startup
ABSENTRY _Startup
; variable/data section
;
ORG RAMStart ; Insert your data definition here
ORG ROMStart
_Startup:
LDA SOPT1 ;Deshabilita COP
AND #%00111111
STA SOPT1
LDHX #RAMEnd+1 ; initialize the stack pointer
TXS
MOV #%00000001,PTBDD
MOV #%00000000,PTCDD
MOV #%00000000,PTAES ;SLEW RATE
MOV #%00000000,PTADD ;IN/OUT
MOV #%00111111,PTAPE ;PULL-UP/PULL-DOWN
MOV #%00001111,PTASC ;INTERRUP STATUS AND CONTROL
MOV #%00001111,PTAPS ;HABILITAR/DES INTERRUPCIONES
;MOV #%00001111,PTAES ;
CLI
INICIO:
BCLR 0,PTBD
ini
JMP ini
;**************************************************************
;* spurious - Spurious Interrupt Service Routine. *
;* (unwanted interrupt) *
;**************************************************************
interrup:
NOP
SEI
BSET 0,PTBD
CLI
RTI
spurious: ; placed here so that security value
NOP ; does not change all the time.
RTI
;**************************************************************
;* Interrupt Vectors *
;**************************************************************
ORG $FFD6
DC.W interrup
ORG $FFFA
DC.W spurious ;
DC.W spurious ; SWI
DC.W _Startup ; Reset
Hello,
There are two problems that I can see -
interrup:
NOP ; Unnecessary instruction
SEI ; Unnecessary instruction
MOV #%00000110 ; Acknowledge interrupt
BSET 0,PTBD
CLI ; Unnecessary instruction
RTI
Regards,
Mac
Hi, thanks you very much for the answer, but i'm still having problems... I can not make that the program works, it is never jumping to the interrupt, can you give me a little more help?
Here is the modified code:
_Startup:
LDA SOPT1 ;Deshabilita COP
AND #%00111111
STA SOPT1
LDHX #RAMEnd+1 ; initialize the stack pointer
TXS
MOV #%00000001,PTBDD
MOV #%00000000,PTCDD
;MOV #%00001111,PTAES ;INTERRUP EDGE
;MOV #%00011111,PTASE ;SLEW RATE
MOV #%00000000,PTADD ;IN/OUT
MOV #%00001111,PTAPE ;PULL-UP/PULL-DOWN
MOV #%00000110,PTASC ;INTERRUP STATUS AND CONTROL
MOV #%00001111,PTAPS ; Enable/disable interrups
CLI
INICIO:
BCLR 0,PTBD
ini
JMP ini
;**************************************************************
;* spurious - Spurious Interrupt Service Routine. *
;* (unwanted interrupt) *
;**************************************************************
interrup:
;NOP
;SEI
MOV #%00000110,PTASC ; Acknowledge interrupt
BSET 0,PTBD
;CLI
;RTI
spurious: ; placed here so that security value
NOP ; does not change all the time.
RTI
;**************************************************************
;* Interrupt Vectors *
;**************************************************************
ORG $FFD6
DC.W interrup
ORG $FFFA
DC.W spurious ;
DC.W spurious ; SWI
DC.W _Startup ; Reset
Thanks,
Gaston.