📄 isr_timers.s
字号:
;START_HEADER
;
; dsPIC30F6014 Demo Source File
; (c) Copyright 2005 Microchip Technology, All rights reserved
;
; --------------------------------------------------------------------------
; File Revision History:
; --------------------------------------------------------------------------
;
; $Log: isr_timers.s,v $
; Revision 1.3 2005/04/04 23:43:51 VasukiH
; Updates to comments in file header
;
; Revision 1.2 2005/04/04 23:15:20 VasukiH
; Updates for MPLAB C30 v1.30 compatiblity
;
; Revision 1.1.1.1 2003/08/23 00:38:32 VasukiH
; First import of demo source into CVS Repository
;
;
;
; --------------------------------------------------------------------------
;
; Software and Development Tools Info:
; --------------------------------------------------------------------------
; Tool Version
; --------------------------------------------------------------------------
; MPLAB IDE 7.0
; MPLAB C30 Toolsuite 1.30
; dsPICDEM(TM) Processor Board 1.10
; --------------------------------------------------------------------------
;
; File Notes:
; 1. Timer1, Timer2, Timer3 and Timer5:4 ISRs in this file
; 2. Timer1 times out every 125 us and allows sending an 8-bit PCM sine wave
; sample via SPI2 to the MCP41010 Digital Potentiometer.
; Timer1 is on only when the ADC is on, i.e. when code execution is in the
; main.s file.
; 3. Timer2 times out every second and increments a 0x0000 - 0x000F up-counter
; visible via the LEDs on Port D
; 4. Timer3 times out and allows the CPU to refresh a data display to
; HyperTerminal via the UART.
; 3. Timer5:Timer4 are used to benchmark some critical routines (FFT, IIR, FIR)
; while operating in 32-bit mode.
;
;END_HEADER
.include "p30fxxxx.inc"
.global ResultDispFlag
.section .ndata, data, near
LEDCounter: .hword 0x000F
ResultDispFlag: .hword 0xFFFF
.global __T1Interrupt, __T2Interrupt
.global __T3Interrupt, __T5Interrupt
.section .text
__T1Interrupt:
cp0 LcdCharCnt ;Check if SPI2 is transmitting
;to the LCD Controller
bra nz, skip_sine_generation ;If yes, then exit ISR
rcall _sub_sine_on_digi_pot ;Else call subroutine to send
;next sample to the Digital Pot.
skip_sine_generation:
bclr IFS0, #T1IF ;Clear the interrupt flag
retfie ;Return from Interrupt
__T2Interrupt:
push.d w0 ;Save w0, w1
dec.b LEDCounter ;LEDs are active-low
mov.b LEDCounter, WREG ;A software counter counting
cp.b w0, #0 ;down from 15 to 0
bra ge, set_LED ;will be able to display
mov.b #15, w0 ;a counter on the LEDs
mov.b WREG, LEDCounter ;that appears to count upward from
set_LED: ;0 through 15.
mov #PORTD, w0 ;Also care is taken not to affect
mov #3, w1 ;any of the other Pins on Port D
btst.b LEDCounter, #0
bsw.z [w0], w1
dec w1, w1
btst.b LEDCounter, #1
bsw.z [w0], w1
dec w1, w1
btst.b LEDCounter, #2
bsw.z [w0], w1
dec w1, w1
btst.b LEDCounter, #3
bsw.z [w0], w1
bclr IFS0, #T2IF ;Clear the interrupt flag
pop.d w0 ;Restore w0, w1
retfie
__T3Interrupt:
setm ResultDispFlag ;Allow CPU to refresh
;data displays on the LCD and UART
bclr IFS0, #T3IF
retfie
__T5Interrupt:
bclr IFS1, #T5IF ;Clear 32-bit timer interrupt flag
retfie
.end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -