6-8
Motorola DSP56000 Family Optimizing C Compiler User’s Manual
For More Information On This Product,
Go to: www.freescale.com
Motorola
Miscellaneous Code
Example 6-6. Interrupt Service Routine
Interrupt Service Routine: This service routine updates the global variable F_ _time at
each SCI timer interrupt. The SCI timer period can be set by programming the SCCR (see
Section 11.2.2.3 of the
DSP56000/DSP56001 User’s Manual
). This program is based on
the y memory model and the SCI interface control registers (X:FFF0 and X:FFF2) should
be initialized for proper SCI timer operation (see Section 11.2 in the
DSP56000/DSP56001 User’s Manual
for detailed information on the SCI operation).
section interrupt
org
global
interrupt1c
move
p:
interrupt1c
(r6)+
; secure the stack pointer
; (refer to section 5.4.1.4)
; save the r2 register
; retrieve the variable _ _time
; increment the variable
; save the result
; restore the r2 register
; return from interrupt service
move
move
move
move
move
rti
endsec
r2,y:(r6)
y:F_ _time,r2
(r2)+
r2,y:F_ _time
y:(r6)-,r2
Notice that fast interrupts can also be programmed by modifying the
crt0
file in the same
way as for the long interrupts (see Chapter 8 of the
DSP56000/DSP56001 User’s Manual
for more information on fast and long interrupts).)
6.7 Miscellaneous Code
There are other data structures and code related to the run-time environment in the crt0
file. They are:
1. Error code variable,
errno
, is a global integer used to record failure codes in C
library calls. This error code variable will exist if C library calls are used. This
variable can be utilized as a debugging aid in order to check which error code is
returned from the C function calls.
2. Heap-stack checking window variable,
_ _stack_safety
, is a global variable
declared in the crt0 file that is used by the heap allocation routines,
malloc()
,
calloc()
and
realloc()
to avoid heap-stack growth collisions. If the distance
between the bottom of the heap and the top of the stack is less than the value
contained in
_ _stack_safety
, then the heap allocation routine will return an error
code indicating that no more memory is available. The value may be set as required
F
Freescale Semiconductor, Inc.
n
.