📄 rs_timer.lis
字号:
0000 ;
0000 ; where INT_MSKN is INT_MSK0 or INT_MSK1 and
0000 ; MASK is the bit set to enable or disable
0000 ;-------------------------------------------------
0000 ; Disable Interrupt Bit Mask(s)
0000 macro M8C_DisableIntMask
0000 if DISABLE_INT_FIX
0000 mov A, reg[CPU_SCR] ; save the current Global interrupt state
0000 M8C_DisableGInt ; disable global interrupts
0000 endif
0000 and reg[@0], ~@1 ; disable specified interrupt enable bit
0000 if DISABLE_INT_FIX
0000 and A, CPUSCR_GIEMask ; determine if global interrupt was set
0000 jz . + 4 ; jump if global interrupt disabled
0000 M8C_EnableGInt ; set global interrupt
0000 endif
0000 macro M8C_EnableIntMask
0000 or reg[@0], @1
0000 macro M8C_EnableWatchDog
0000 ; Clearing the Power-On Reset bit starts up the Watchdog timer
0000 ; See the 25xxx/26xxx Family Datasheet, Section 9.3.4.
0000 and reg[CPU_SCR], ~CPUSCR_PORSMask & ~CPUSCR_WDRSMask
0000 macro M8C_ClearWDT
0000 mov reg[RES_WDT], 00h
0000 macro M8C_ClearWDTAndSleep
0000 mov reg[RES_WDT], 38h
0000 macro M8C_Stall
0000 or reg[ASY_CR], ASY_CR_SYNCEN
0000 macro M8C_Unstall
0000 and reg[ASY_CR], ~ASY_CR_SYNCEN
0000 macro M8C_Sleep
0000 or reg[CPU_SCR], CPUSCR_SleepMask
0000 ; The next instruction to be executed depends on the state of the
0000 ; various interrupt enable bits. If some interrupts are enabled
0000 ; and the global interrupts are disabled, the next instruction will
0000 ; be the one that follows the invocation of this macro. If global
0000 ; interrupts are also enabled then the next instruction will be
0000 ; from the interrupt vector table. If no interrupts are enabled
0000 ; then RIP.
0000 macro M8C_Stop
0000 ; In general, you probably don't want to do this, but here's how:
0000 or reg[CPU_SCR], CPUSCR_StopMask
0000 ; Next instruction to be executed is located in the interrupt
0000 ; vector table entry for Power-On Reset.
0000 macro M8C_Reset
0000 ; Restore everything to the power-on reset state.
0000 mov A, 0
0000 SSC
0000 ; Next non-supervisor instruction will be at interrupt vector 0.
0000 macro SSC
0000 db 0
0008 bRs_Timer_INT_MASK: equ 08h
0000 ;timer8 interrupt address
00E1 Rs_Timer_INT_REG: equ 0e1h
0000
0000 ;---------------------------------
0000 ; Registers used by timer8
0000 ;---------------------------------
002F Rs_Timer_CONTROL_REG: equ 2fh ;Control register
002C Rs_Timer_COUNTER_REG: equ 2ch ;Counter register
002D Rs_Timer_PERIOD_REG: equ 2dh ;Period value register
002E Rs_Timer_COMPARE_REG: equ 2eh ;CompareValue register
002C Rs_Timer_FUNC_REG: equ 2ch ;Function register
002D Rs_Timer_INPUT_REG: equ 2dh ;Input register
002E Rs_Timer_OUTPUT_REG: equ 2eh ;Output register
0000
0000 ; end of file
0000
0000
area text (ROM, REL)
;-------------------------------------------------------------------
; Declare the functions global for both assembler and C compiler.
;
; Note that there are two names for each API. First name is
; assembler reference. Name with underscore is name refence for
; C compiler. Calling function in C source code does not require
; the underscore.
;-------------------------------------------------------------------
export Rs_Timer_EnableInt
export _Rs_Timer_EnableInt
export Rs_Timer_DisableInt
export _Rs_Timer_DisableInt
export Rs_Timer_Start
export _Rs_Timer_Start
export Rs_Timer_Stop
export _Rs_Timer_Stop
export Rs_Timer_WritePeriod
export _Rs_Timer_WritePeriod
export Rs_Timer_WriteCompareValue
export _Rs_Timer_WriteCompareValue
export bRs_Timer_ReadCompareValue
export _bRs_Timer_ReadCompareValue
export bRs_Timer_ReadTimer
export _bRs_Timer_ReadTimer
export bRs_Timer_ReadTimerSaveCV
export _bRs_Timer_ReadTimerSaveCV
export bRs_Timer_ReadCounter ; obsolete
export _bRs_Timer_ReadCounter ; obsolete
export bRs_Timer_CaptureCounter ; obsolete
export _bRs_Timer_CaptureCounter ; obsolete
;-----------
; EQUATES
;-----------
0001 bfCONTROL_REG_START_BIT: equ 1 ; Control register start bit
0000
0000 ;-----------------------------------------------------------------------------
0000 ; FUNCTION NAME: Rs_Timer_EnableInt
0000 ;
0000 ; DESCRIPTION:
0000 ; Enables this Timer's interrupt by setting the interrupt enable mask bit
0000 ; associated with this User Module. Remember to call the global interrupt
0000 ; enable function by using the macro: M8C_EnableGInt.
0000 ;
0000 ; ARGUMENTS:
0000 ; none.
0000 ;
0000 ; RETURNS:
0000 ; none.
0000 ;
0000 ; SIDE EFFECTS:
0000 ; none.
0000 ;
0000 ; THEORY of OPERATION:
0000 ; Sets the specific user module interrupt enable mask bit.
0000 ;
0000 ;-----------------------------------------------------------------------------
0000 Rs_Timer_EnableInt:
0000 _Rs_Timer_EnableInt:
0000 43E108 or reg[Rs_Timer_INT_REG], bRs_Timer_INT_MASK
0003 7F ret
0004
0004
0004 ;-----------------------------------------------------------------------------
0004 ; FUNCTION NAME: Rs_Timer_DisableInt
0004 ;
0004 ; DESCRIPTION:
0004 ; Disables this timer's interrupt by clearing the interrupt enable mask bit
0004 ; associated with this User Module.
0004 ;
0004 ; ARGUMENTS:
0004 ; none.
0004 ;
0004 ; RETURNS:
0004 ; none.
0004 ;
0004 ; SIDE EFFECTS:
0004 ; none.
0004 ;
0004 ; THEORY of OPERATION:
0004 ; Clears the specific user module interrupt enable mask bit.
0004 ;
0004 ;-----------------------------------------------------------------------------
0004 Rs_Timer_DisableInt:
0004 _Rs_Timer_DisableInt:
if DISABLE_INT_FIX
0004 5DFF mov A, reg[CPU_SCR] ; save the current Global interrupt state
0006 70FE and F, ~FlagGlobalIE
endif
0008 41E1F7 and reg[Rs_Timer_INT_REG], ~bRs_Timer_INT_MASK ; disable specified interrupt enable bit
if DISABLE_INT_FIX
000B 2180 and A, CPUSCR_GIEMask ; determine if global interrupt was set
000D A003 jz . + 4 ; jump if global interrupt disabled
000F 7101 or F, FlagGlobalIE
endif
0011 7F ret
0012
0012
0012 ;-----------------------------------------------------------------------------
0012 ; FUNCTION NAME: Rs_Timer_Start
0012 ;
0012 ; DESCRIPTION:
0012 ; Sets the start bit in the Control register of this user module. The
0012 ; timer will begin counting on the next input clock.
0012 ;
0012 ; ARGUMENTS:
0012 ; none.
0012 ;
0012 ; RETURNS:
0012 ; none.
0012 ;
0012 ; SIDE EFFECTS:
0012 ; none.
0012 ;
0012 ; THEORY of OPERATION:
0012 ; Set the start bit in the Control register.
0012 ;
0012 ;-----------------------------------------------------------------------------
0012 Rs_Timer_Start:
0012 _Rs_Timer_Start:
0012 432F01 or REG[Rs_Timer_CONTROL_REG], bfCONTROL_REG_START_BIT
0015 7F ret
0016
0016
0016 ;-----------------------------------------------------------------------------
0016 ; FUNCTION NAME: Rs_Timer_Stop
0016 ;
0016 ; DESCRIPTION:
0016 ; Disables Timer operation.
0016 ;
0016 ; ARGUMENTS:
0016 ; none.
0016 ;
0016 ; RETURNS:
0016 ; none.
0016 ;
0016 ; SIDE EFFECTS:
0016 ; After this function completes, the Counter register will latch any data
0016 ; written to the Period register. Writing to the Period register is
0016 ; performed using the Rs_Timer_WritePeriod function.
0016 ;
0016 ; THEORY of OPERATION:
0016 ; Clear the start bit in the Control register.
0016 ;
0016 ;-----------------------------------------------------------------------------
0016 Rs_Timer_Stop:
0016 _Rs_Timer_Stop:
0016 412FFE and REG[Rs_Timer_CONTROL_REG], ~bfCONTROL_REG_START_BIT
0019 7F ret
001A
001A
001A ;-----------------------------------------------------------------------------
001A ; FUNCTION NAME: Rs_Timer_WritePeriod
001A ;
001A ; DESCRIPTION:
001A ; Write the period value into the Period register.
001A ;
001A ; ARGUMENTS:
001A ; BYTE bPeriodValue - period count - passed in the Accumulator.
001A ;
001A ; RETURNS:
001A ; none.
001A ;
001A ; SIDE EFFECTS:
001A ; If the Timer user module is stopped, then this value will also be
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -