📄 pwm16_2.lis
字号:
0000 ;
0000 ; This is a fix to a noted problem in which an
0000 ; inadvertant reset can occur if an interrupt occurs
0000 ; while clearing an interrupt mask bit.
0000 ;
0000 ; Usage: M8C_DisableIntMask INT_MSKN, MASK
0000 ; M8C_EnableIntMask INT_MSKN, MASK
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 bPWM16_2_INT_MASK: equ 08h
0000 ;PWM16 interrupt address
00E1 PWM16_2_INT_REG: equ 0e1h
0000
0000
0000 ;---------------------------------
0000 ; Registers used by PWM16
0000 ;---------------------------------
002B PWM16_2_CONTROL_LSB_REG: equ 2bh ;Control register LSB
002F PWM16_2_CONTROL_MSB_REG: equ 2fh ;Control register MSB
0028 PWM16_2_COUNTER_LSB_REG: equ 28h ;Counter register LSB
002C PWM16_2_COUNTER_MSB_REG: equ 2ch ;Counter register MSB
0029 PWM16_2_PERIOD_LSB_REG: equ 29h ;Period register LSB
002D PWM16_2_PERIOD_MSB_REG: equ 2dh ;Period register MSB
002A PWM16_2_PWDITH_LSB_REG: equ 2ah ;PulseWidth register LSB
002E PWM16_2_PWDITH_MSG_REG: equ 2eh ;PulseWidth register MSB
0028 PWM16_2_FUNC_LSB_REG: equ 28h ;Function register LSB
002C PWM16_2_FUNC_MSB_REG: equ 2ch ;Function register MSB
0029 PWM16_2_INPUT_LSB_REG: equ 29h ;Input register LSB
002D PWM16_2_INPUT_MSB_REG: equ 2dh ;Input register MSB
002A PWM16_2_OUTPUT_LSB_REG: equ 2ah ;Output register LSB
002E PWM16_2_OUTPUT_MSB_REG: equ 2eh ;Output register MSB
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 PWM16_2_EnableInt
export _PWM16_2_EnableInt
export PWM16_2_DisableInt
export _PWM16_2_DisableInt
export PWM16_2_Start
export _PWM16_2_Start
export PWM16_2_Stop
export _PWM16_2_Stop
export PWM16_2_WritePeriod
export _PWM16_2_WritePeriod
export PWM16_2_WritePulseWidth
export _PWM16_2_WritePulseWidth
export wPWM16_2_ReadPulseWidth
export _wPWM16_2_ReadPulseWidth
export wPWM16_2_ReadCounter
export _wPWM16_2_ReadCounter
;-----------
; EQUATES
;-----------
0001 bfCONTROL_REG_START_BIT: equ 1 ; Control register start bit
000F bfINPUT_REG_CLOCK_MASK: equ 0Fh ; input register clock mask
0000 bfINPUT_REG_NULL: equ 00h ; clear the input register
0030 bfINPUT_REG_PREV_MASK: equ 30h ; input register input-previous
0000
0000 ;-----------------------------------------------------------------------------
0000 ; FUNCTION NAME: PWM16_2_EnableInt
0000 ;
0000 ; DESCRIPTION:
0000 ; Enables this PWM'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 PWM16_2_EnableInt:
0000 _PWM16_2_EnableInt:
0000 43E108 or reg[PWM16_2_INT_REG], bPWM16_2_INT_MASK
0003 7F ret
0004
0004
0004 ;-----------------------------------------------------------------------------
0004 ; FUNCTION NAME: PWM16_2_DisableInt
0004 ;
0004 ; DESCRIPTION:
0004 ; Disables this PWM'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 PWM16_2_DisableInt:
0004 _PWM16_2_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[PWM16_2_INT_REG], ~bPWM16_2_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: PWM16_2_Start
0012 ;
0012 ; DESCRIPTION:
0012 ; Sets the start bit in the Control register of this user module. The
0012 ; PWM will begin counting on the next input clock as soon as the
0012 ; enable input is asserted high.
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 of the LSB block.
0012 ;
0012 ;-----------------------------------------------------------------------------
0012 PWM16_2_Start:
0012 _PWM16_2_Start:
0012 432B01 or REG[PWM16_2_CONTROL_LSB_REG], bfCONTROL_REG_START_BIT
0015 7F ret
0016
0016
0016 ;-----------------------------------------------------------------------------
0016 ; FUNCTION NAME: PWM16_2_Stop
0016 ;
0016 ; DESCRIPTION:
0016 ; Disables PWM 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 PWM16_2_WritePeriod function.
0016 ;
0016 ; THEORY of OPERATION:
0016 ; Clear the start bit in the Control register of the LSB block.
0016 ;
0016 ;-----------------------------------------------------------------------------
0016 PWM16_2_Stop:
0016 _PWM16_2_Stop:
0016 412BFE and REG[PWM16_2_CONTROL_LSB_REG], ~bfCONTROL_REG_START_BIT
0019 7F ret
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -