⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 init_timers.s

📁 该文件包含30F的电机控制程序
💻 S
字号:
;START_HEADER
;
; dsPIC30F6014 Demo Source File
; (c) Copyright 2005 Microchip Technology, All rights reserved
;
; --------------------------------------------------------------------------
; File Revision History:
; --------------------------------------------------------------------------
;
; $Log: init_timers.s,v $
; Revision 1.3  2005/04/04 23:44:18  VasukiH
; Updates to comments in file header
;
; Revision 1.2  2005/04/04 23:15:50  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. Initialization routines for Timers1-5
; 2. Timers 1,2 and 3 operate as 16-bit timers
; 3. Timer4 and 5 operate together as a 32-bit timer
; 4. Please see comments preceding each subroutine
;
;END_HEADER



.include "p30fxxxx.inc"
.include "common.inc"


;The following routines in this file have been provided global visibility

.global _init_timer1_16b
.global _init_timer2_16b
.global _init_timer3_16b
.global _init_timer45_32b


.section .text

;..............................................................................
;Subroutine: Initialization of Timer3 to operate as  a 16-bit timer
;            that enables refreshing the displays with new values
;            In the absence of this, the HyperTerminal session window
;            will refresh so fast that human viewing of results may be
;            impossible
;..............................................................................

_init_timer3_16b:                       ; Timer B/C type

        clr     T3CON                   ; Set module to known state
        clr     TMR3                    ; Ensure timer3 counter is reset

        bset    T3CON, #TCKPS1          ; Set the Timer Prescaler to the
        bset    T3CON, #TCKPS0          ; 1:256 option

        mov     #0x7FFF, W0             ; Initialize Period Register 3
        mov     W0, PR3                 ; for 1.14 seconds


        bclr    IFS0, #T3IF             ; Reset timer3 interrupt flag

        bclr    IPC1, #T3IP2            ; Set timer3 interrupt priority
        bset    IPC1, #T3IP1
        bset    IPC1, #T3IP0

        bset    IEC0, #T3IE             ; Enable timer3 ISR processing

        ; We are not enabling the timer yet
        ; It will be enabled in the main routine

        return

;..............................................................................
;Subroutine: Initialization of Timer2 to operate as  a 16-bit timer
;            that lights up LEDs in a 0x0 - 0xF up-counting sequence
;..............................................................................

_init_timer2_16b:

        clr     T2CON                   ; Set module to known state
        clr     TMR2                    ; Ensure timer2 counter is reset

        bset    T2CON, #TCKPS1          ; Set the Timer Prescaler to the
        bset    T2CON, #TCKPS0          ; 1:256 option

        mov     #period_1000ms, W0      ; Initialize Period Register 2
        mov     W0, PR2                 ; for 1 second


        bclr    IFS0, #T2IF             ; Reset timer2 interrupt flag

        bclr    IPC1, #T2IP2            ; Set timer2 interrupt priority
        bset    IPC1, #T2IP1
        bset    IPC1, #T2IP0

        bset    IEC0, #T2IE             ; Enable timer2 interrupt

        bset    T2CON, #TON             ; Start timer2

        return

;..............................................................................
;Subroutine: Initialization of Timer4 and Timer5 to
;            operate together as one 32-bit timer
;..............................................................................

_init_timer45_32b:                      ; Timer B/C type

        clr     T4CON                   ; Set module to known state
        clr     TMR4                    ; Ensure timer4 counter is reset
        clr     TMR5                    ; Ensure timer5 counter is reset

        mov     #0xFFFF, W0
        mov     W0, PR4                 ; Initialize Period Register 4
        mov     #0xFFFF, W0             ; and
        mov     W0, PR5                 ; Period Register 5 for 100 milliseconds

        bclr    IFS1, #T5IF             ; Reset timer5 interrupt flag

        bclr    IPC5, #T5IP2
        bset    IPC5, #T5IP1
        bset    IPC5, #T5IP0

        bset    IEC1, #T5IE             ; Enable timer 5 interrupt

        bset    T4CON, #T32             ; Enable 32-bit timer mode


        return




;..............................................................................
;Subroutine: Initialization of Timer1 as a 16-bit timer to time-out at 8000Hz
;            This time-out initiates communication with the MCP41010
;..............................................................................

_init_timer1_16b:

        clr     T1CON                   ; Set module to known state
        clr     TMR1                    ; Ensure timer1 counter is reset

        mov     #0x0399, w0
        mov     W0, PR1                 ; Initialize Period Register 1 for 125us


        bclr    IFS0, #T1IF             ; Reset timer1 interrupt flag


        bset    IEC0, #T1IE             ; Enable timer 1 ISR processing


        return


.end




⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -