Hand-Coded Assembly Isr Allowing Nesting Of Interrupts - Texas Instruments TMS320C6000 Programmer's Manual

Hide thumbs Also See for TMS320C6000:
Table of Contents

Advertisement

Interrupt Subroutines
Example 7–8. Hand-Coded Assembly ISR Allowing Nesting of Interrupts
* Assume Register B0–B5 & A0 are the only registers used by the
* ISR and no other functions are called
STW
B0,*B15––
|| MVC
IRP, B0
STW
A0,*B15––
|| MVC
IER, B1
|| MVK
mask,A0
STW
B1,*B15––
|| MVC
A0, IER
STW
B2,*B15––
|| MVC
CSR,A0
STW
B3,*B15––
|| OR
1,A0,A0
STW
B4,*B15––
STW
B5,*B15––
|| MVC
A0,CSR
STW
B0,*B15––
STW
B1,*B15––
STW
A0,*B15––
* Beginning of ISR code
...
* End of ISR code
B
restore
MVKL
0FFFEh,A0
MVKLH 0FFFFh,A0
MVC
CSR,B5
AND
A0,B5,B5
MVC
B5,CSR
restore
LDW
*++B15,A0
LDW
*++B15,B1
LDW
*++B15,B0
LDW
*++B15,B4
LDW
*++B15,B3
LDW
*++B15,B5
LDW
*++B15,B2
|| MVC
B0,IRP
B
IRP
LDW
*++B15,B1
MVC
B1,IER
LDW
*++B15,A0
LDW
*++B15,B0
MVC
A0,CSR
7-14
; store B0 to stack
; save IRP
; store A0 to stack
; save IER
; setup a new IER (if desirable)
; store B1 to stack
; setup a new IER (if desirable)
; store B2 to stack
; read current CSR
; store B3 to stack
; set GIE bit field in CSR
; store B4 to stack
; store B5 to stack
; write new CSR with GIE enabled
; store B0 to stack (contains IRP)
; store B1 to stack (contains IER)
; store A0 to stack (original CSR)
; Branch to restore routine
; disable CSR in delay slots of branch
; create mask to disable GIE bit
; read current CSR
; AND B5 with mask
; write new CSR with GIE disabled
; restore routine begins at next line
; restore A0 (original CSR)
; restore B1 (contains IER)
; restore B0 (contains IRP)
; restore B4
; restore B3
; restore B5
; restore B2
; restore original IRP
; return from interrupt
; restore B1
; restore original IER
; restore A0
; restore B0
; restore original CSR
; to complete before branch is taken

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents