| Electronic Components Datasheet Search |
|
PIC16F818-E/ML Datasheet(PDF) 64 Page - Microchip Technology |
|
|
|||||||||||||||||||||||||||||
PIC16F818-E/ML Datasheet(HTML) 64 Page - Microchip Technology |
|
64 / 176 page ![]() PIC16F818/819 DS39598E-page 62 2004 Microchip Technology Inc. EXAMPLE 7-3: IMPLEMENTING A REAL-TIME CLOCK USING A TIMER1 INTERRUPT SERVICE TABLE 7-2: REGISTERS ASSOCIATED WITH TIMER1 AS A TIMER/COUNTER RTCinit BANKSEL TMR1H MOVLW 0x80 ; 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 BANKSEL PIE1 BSF PIE1, TMR1IE ; Enable Timer1 interrupt RETURN RTCisr BANKSEL TMR1H BSF TMR1H, 7 ; Preload for 1 sec overflow BCF PIR1, TMR1IF ; Clear interrupt flag INCF secs, F ; Increment seconds MOVF secs, w SUBLW .60 BTFSS STATUS, Z ; 60 seconds elapsed? RETURN ; No, done CLRF seconds ; Clear seconds INCF mins, f ; Increment minutes MOVF mins, w SUBLW .60 BTFSS STATUS, Z ; 60 seconds elapsed? RETURN ; No, done CLRF mins ; Clear minutes INCF hours, f ; Increment hours MOVF hours, w SUBLW .24 BTFSS STATUS, Z ; 24 hours elapsed? RETURN ; No, done CLRF hours ; Clear hours RETURN ; Done Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value on POR, BOR Value on all other Resets 0Bh,8Bh, 10Bh,18Bh INTCON GIE PEIE TMR0IE INTE RBIE TMR0IF INTF RBIF 0000 000x 0000 000u 0Ch PIR1 — ADIF — — SSPIF CCP1IF TMR2IF TMR1IF -0-- 0000 -0-- 0000 8Ch PIE1 — ADIE — — SSPIE CCP1IE TMR2IE TMR1IE -0-- 0000 -0-- 0000 0Eh TMR1L Holding Register for the Least Significant Byte of the 16-bit TMR1 Register xxxx xxxx uuuu uuuu 0Fh TMR1H Holding Register for the Most Significant Byte of the 16-bit TMR1 Register xxxx xxxx uuuu uuuu 10h T1CON — — T1CKPS1 T1CKPS0 T1OSCEN T1SYNC TMR1CS TMR1ON --00 0000 --uu uuuu Legend: x = unknown, u = unchanged, - = unimplemented, read as ‘0’. Shaded cells are not used by the Timer1 module. |
|
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 |
| 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 |