EasyManua.ls Logo

Microchip Technology dsPIC30F - Page 261

Microchip Technology dsPIC30F
738 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
© 2004 Microchip Technology Inc. DS70059C-page 12-19
Section 12. Timers
Timers
12
12.10.2 Synchronous Counter Mode
The 32-bit timer operates similarly to a 16-bit timer in Synchronous Counter mode. Example 12-6
shows how to configure a 32-bit timer in Synchronous Counter mode. This example assumes
Timer2 is a Type B time base and Timer3 is a Type C time base.
Example 12-6: Initialization Code for 32-bit Synchronous Counter Mode Using an
External Clock Input
; The following code example will enable Timer2 interrupts, load
; the Timer3:Timer2 Period register and start the 32-bit timer
; module consisting of Timer3 and Timer2.
; When a 32-bit period match interrupt occurs, the user must clear
; the Timer3 interrupt status flag in the software.
CLR T2CON ; Stops any 16/32-bit Timer2 operation
CLR T3CON ; Stops any 16-bit Timer3 operation
CLR TMR3 ; Clear contents of the Timer3 timer register
CLR TMR2 ; Clear contents of the Timer2 timer register
MOV #0xFFFF, w0 ; Load the Period Register3
MOV w0, PR3 ; with the value 0xFFFF
MOV w0, PR2 ; Load the Period Register2 with value 0xFFFF
BSET IPC1, #T3IP0 ; Setup Timer3 interrupt for
BCLR IPC1, #T3IP1 ; desired priority level
BCLR IPC1, #T3IP2 ; (this example assigns level 1 priority)
BCLR IFS0, #T3IF ; Clear the Timer3 interrupt status flag
BSET IEC0, #T3IE ; Enable Timer3 interrupts
MOV #0x801A, w0 ; Enable 32-bit Timer operation and start
MOV w0, T2CON ; 32-bit timer with prescaler settings at
; 1:8 and clock source set to external clock
; Example code for Timer3 ISR
__T3Interrupt:
BCLR IFS0, #T3IF ; Reset Timer3 interrupt flag
; User code goes here.
RETFIE ; Return from ISR

Table of Contents

Other manuals for Microchip Technology dsPIC30F