Electronic Components Datasheet Search
  New Zealand  ▼
ALLDATASHEET.CO.NZ

X  

PIC18F2420-E/P Datasheet(PDF) 133 Page - Microchip Technology

Part # PIC18F2420-E/P
Description  28/40/44-Pin Enhanced Flash Microcontrollers with 10-Bit A/D and nanoWatt Technology
PDF  412 Pages
Scroll/Zoom Zoom In 100%  Zoom Out
Manufacturer  MICROCHIP [Microchip Technology]
Direct Link  http://www.microchip.com
Logo MICROCHIP - Microchip Technology

PIC18F2420-E/P Datasheet(HTML) 133 Page - Microchip Technology

Back Button PIC18F2420-E/P Datasheet HTML 129Page - Microchip Technology PIC18F2420-E/P Datasheet HTML 130Page - Microchip Technology PIC18F2420-E/P Datasheet HTML 131Page - Microchip Technology PIC18F2420-E/P Datasheet HTML 132Page - Microchip Technology PIC18F2420-E/P Datasheet HTML 133Page - Microchip Technology PIC18F2420-E/P Datasheet HTML 134Page - Microchip Technology PIC18F2420-E/P Datasheet HTML 135Page - Microchip Technology PIC18F2420-E/P Datasheet HTML 136Page - Microchip Technology PIC18F2420-E/P Datasheet HTML 137Page - Microchip Technology Next Button
Zoom Inzoom in Zoom Outzoom out
 133 / 412 page
background image
© 2008 Microchip Technology Inc.
DS39631E-page 131
PIC18F2420/2520/4420/4520
12.7
Considerations in Asynchronous
Counter Mode
Following a Timer1 interrupt and an update to the
TMR1 registers, the Timer1 module uses a falling edge
on its clock source to trigger the next register update on
the rising edge. If the update is completed after the
clock input has fallen, the next rising edge will not be
counted.
If the application can reliably update TMR1 before the
timer input goes low, no additional action is needed.
Otherwise, an adjusted update can be performed
following a later Timer1 increment. This can be done by
monitoring TMR1L within the interrupt routine until it
increments, and then updating the TMR1H:TMR1L
register pair while the clock is low, or one-half of the
period of the clock source. Assuming that Timer1 is
being used as a Real-Time Clock, the clock source is a
32.768 kHz crystal oscillator; in this case, one half
period of the clock is 15.25
μs.
The Real-Time Clock application code in Example 12-1
shows a typical ISR for Timer1, as well as the optional
code required if the update cannot be done reliably
within the required interval.
EXAMPLE 12-1:
IMPLEMENTING A REAL-TIME CLOCK USING A TIMER1 INTERRUPT SERVICE
RTCinit
MOVLW
80h
; Preload TMR1 register pair
MOVWF
TMR1H
; for 1 second overflow
CLRF
TMR1L
MOVLW
b’00001111’
; Configure for external clock,
MOVWF
T1CON
; Asynchronous operation, external oscillator
CLRF
secs
; Initialize timekeeping registers
CLRF
mins
;
MOVLW
.12
MOVWF
hours
BSF
PIE1, TMR1IE
; Enable Timer1 interrupt
RETURN
RTCisr
; Start ISR here
; Insert the next 4 lines of code when TMR1
; can not be reliably updated before clock pulse goes low
BTFSC
TMR1L,0
; wait for TMR1L<0> to become clear
BRA
$-2
; (may already be clear)
BTFSS
TMR1L,0
; wait for TMR1L<0> to become set
BRA
$-2
; TMR1 has just incremented
; If TMR1 update can be completed before clock pulse goes low
BSF
TMR1H, 7
; Preload for 1 sec overflow
BCF
PIR1, TMR1IF
; Clear interrupt flag
INCF
secs, F
; Increment seconds
MOVLW
.59
; 60 seconds elapsed?
CPFSGT
secs
RETURN
; No, done
CLRF
secs
; Clear seconds
INCF
mins, F
; Increment minutes
MOVLW
.59
; 60 minutes elapsed?
CPFSGT
mins
RETURN
; No, done
CLRF
mins
; clear minutes
INCF
hours, F
; Increment hours
MOVLW
.23
; 24 hours elapsed?
CPFSGT
hours
RETURN
; No, done
CLRF
hours
; Reset hours
RETURN
; Done



Html Pages

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100  ...More


Datasheet Download

Go To PDF Page


Link URL



Does ALLDATASHEET help your business so far?  [ DONATE ] 

About Alldatasheet   |   Advertisement   |   Contact us   |   Privacy Policy   |   Link to Datasheet    |   Link Exchange   |   Manufacturer List
All Rights Reserved©Alldatasheet.com


Mirror Sites
English : Alldatasheet.com  |   English : Alldatasheet.net  |   Chinese : Alldatasheetcn.com  |   German : Alldatasheetde.com  |   Japanese : Alldatasheet.jp
Russian : Alldatasheetru.com  |   Korean : Alldatasheet.co.kr  |   Spanish : Alldatasheet.es  |   French : Alldatasheet.fr  |   Italian : Alldatasheetit.com
Portuguese : Alldatasheetpt.com  |   Polish : Alldatasheet.pl  |   Vietnamese : Alldatasheet.vn
Indian : Alldatasheet.in  |   Mexican : Alldatasheet.com.mx  |   British : Alldatasheet.co.uk  |   New Zealand : Alldatasheet.co.nz
Family Site : ic2ic.com  |   icmetro.com