PIC16C73B-20I/SO

TIMER1 MODULE
DS80329B-page 4 2010 Microchip Technology Inc.
EXAMPLE 2: PIC12/14/16/17 CODE EXAMPLE FOR OVERFLOW PERIODS OTHER THAN 1
SECOND OR USING AN OSCILLATOR OTHER THAN 32.768 kHZ
EXAMPLE 3: PIC18 HIGH-PRIORITY INTERRUPT SERVICE ROUTINE
BTFSC TMR1L, 0
GOTO $-1
BTFSS TMR1L, 0
GOTO $-1 ;Timer has just incremented, 31μs before next rising
edge to complete reload.
BCF T1CON, TMR1CS ;Select system clock for Timer1.
MOVF TMR1, W ;Sample low byte of Timer1 before increments.
ADDWF TMR1_Reload_lo, F ;Add reload value for low byte
BTFSC STATUS, C ;if this generates a carry then
INCF TMR1_Reload_hi, F ;modify the reload value for the high byte.
MOVF TMR1_Reload_hi, W ;Reload Timer1 high byte.
MOVWF TMR1H
MOVF TMR1_Reload_lo, W ;Reload Timer1 low byte.
MOVW TMR1L
BCF T1CON, TMR1ON ;Timer1 off.
BSF T1CON, TMR1CS ;Select external crystal.
BSF T1CON, TMR1ON ;Timer1 on.
Critical Timing of code sequence for instructions.
HIntVector code 0x0008 ; (3-4Tcy), fixed interrupt latency
goto HighISR ; (3Tcy) jump to high priority ISR code
code ; unprotected code space
HighISR:
btfss PIR1,TMR1IF ; (1Tcy) TMR1 overflow?
goto NextISR ; (2Tcy) No, check another interrupt source
; Insert the next 4 lines of code when TMR1 can not
; be reliably updated before clock pulse goes low
RTCisr:
btfsc TMR1L,0 ; wait for TMR1L<0> to become clear
bra $-2 ; may already be clear (loops for 0 to 30.5us)
btfss TMR1L,0 ; wait for TMR1L<0> to become set
bra $-2 ; (loops for 30.5us)
; If TMR1 update can be completed before clock pulse
; goes low, start update here
Update:
bsf TMR1H,7 ; reload for next 1 second overflow
bcf PIR1,TMR1IF ; clear flag
incf Seconds,F ; record second
retfie FAST
NextISR: ; Another interrupt source...
.... ; code for other interrupts, if needed
retfieFAST
2010 Microchip Technology Inc. DS80329B-page 5
TIMER1 MODULE
REVISION HISTORY
Rev A Document (7/2007)
Initial release of this errata.
Rev B Document (
03/2010)
Added PIC12F617 device to the Clarifications/
Corrections to the Data Sheet section.
TIMER1 MODULE
DS80329B-page 6 2010 Microchip Technology Inc.
NOTES:

PIC16C73B-20I/SO

Mfr. #:
Manufacturer:
Microchip Technology
Description:
8-bit Microcontrollers - MCU 7KB 192 RAM 22 I/O
Lifecycle:
New from this manufacturer.
Delivery:
DHL FedEx Ups TNT EMS
Payment:
T/T Paypal Visa MoneyGram Western Union