/* This C language subroutine provides support for the on-chip timer of the ADSP-21020. The Run Time Library for the C Language. Gordon A. Sterling (617) 461 - 3076 DSP Development Tools Engineering Created on 1/4/91 Updated on 5/94 by AS #include <21020.h>
int timer_set(unsigned int tperiod, unsigned int tcount); unsigned int timer_on(void); unsigned int timer_off(void); */ #include "lib_glob.h" #include "020_glob.h" .SEGMENT/CODE Code_Space_Name; .FILE RTL_FILENAME; .GLOBAL _timer_set, _timer_on, _timer_off; _timer_on: FETCH_RETURN JUMP (PC, restore_state) (DB); BIT SET MODE2 32; /*Enable timer*/ R0=TCOUNT; _timer_off: FETCH_RETURN JUMP (PC, restore_state) (DB); BIT CLR MODE2 32; /*Disable timer*/ R0=TCOUNT; _timer_set: FETCH_RETURN TPERIOD=R4; TCOUNT=R8; R0=MODE2; R0=FEXT R0 BY 5:1; /*Deposit bit 5 into LSB of R0*/ restore_state: RETURN (DB); RESTORE_STACK RESTORE_FRAME .ENDSEG;