欢迎访问ic37.com |
会员登录 免费注册
发布采购

PIC16F767-I/SP 参数 Datasheet PDF下载

PIC16F767-I/SP图片预览
型号: PIC16F767-I/SP
PDF下载: 下载PDF文件 查看货源
内容描述: 28 /40/ 44引脚, 8位CMOS闪存微控制器与10位A / D和纳瓦技术 [28/40/44-Pin, 8-Bit CMOS Flash Microcontrollers with 10-Bit A/D and nanoWatt Technology]
分类和应用: 闪存微控制器和处理器外围集成电路光电二极管时钟
文件页数/大小: 276 页 / 4898 K
品牌: MICROCHIP [ MICROCHIP TECHNOLOGY ]
 浏览型号PIC16F767-I/SP的Datasheet PDF文件第80页浏览型号PIC16F767-I/SP的Datasheet PDF文件第81页浏览型号PIC16F767-I/SP的Datasheet PDF文件第82页浏览型号PIC16F767-I/SP的Datasheet PDF文件第83页浏览型号PIC16F767-I/SP的Datasheet PDF文件第85页浏览型号PIC16F767-I/SP的Datasheet PDF文件第86页浏览型号PIC16F767-I/SP的Datasheet PDF文件第87页浏览型号PIC16F767-I/SP的Datasheet PDF文件第88页  
PIC16F7X7
7.9
Resetting Timer1 Register Pair
(TMR1H, TMR1L)
battery or supercapacitor as a power source, it can
completely eliminate the need for a separate RTC
device and battery backup.
The application code routine,
RTCisr,
shown in
increment a counter at one-second intervals using an
Interrupt Service Routine. Incrementing the TMR1 reg-
ister pair to overflow, triggers the interrupt and calls the
routine which increments the seconds counter by one;
additional counters for minutes and hours are
incremented as the previous counter overflows.
Since the register pair is 16 bits wide, counting up to
overflow the register directly from a 32.768 kHz clock
would take 2 seconds. To force the overflow at the
required one-second intervals, it is necessary to
preload it. The simplest method is to set the MSb of
TMR1H with a
BSF
instruction. Note that the TMR1L
register is never preloaded or altered; doing so may
introduce cumulative error over many cycles.
For this method to be accurate, Timer1 must operate in
Asynchronous mode and the Timer1 overflow interrupt
must be enabled (PIE1<0> =
1)
as shown in the
routine,
RTCinit.
The Timer1 oscillator must also be
enabled and running at all times.
TMR1H and TMR1L registers are not reset to 00h on a
POR, or any other Reset, except by the CCP1 special
event triggers.
T1CON register is reset to 00h on a Power-on Reset or
a Brown-out Reset, which shuts off the timer and
leaves a 1:1 prescale. In all other Resets, the register
is unaffected.
7.10
Timer1 Prescaler
The prescaler counter is cleared on writes to the
TMR1H or TMR1L registers.
7.11
Using Timer1 as a Real-Time Clock
Adding an external LP oscillator to Timer1 (such as the
one described in
gives users the option to include RTC functionality in
their applications. This is accomplished with an inex-
pensive watch crystal to provide an accurate time base
and several lines of application code to calculate the
time. When operating in Sleep mode and using a
EXAMPLE 7-3:
RTCinit
IMPLEMENTING A REAL-TIME CLOCK USING A TIMER1 INTERRUPT SERVICE
TMR1H
0x80
TMR1H
TMR1L
b’00001111’
T1CON
secs
mins
.12
hours
PIE1
PIE1, TMR1IE
TMR1H
TMR1H, 7
PIR1, TMR1IF
secs, F
secs, w
.60
STATUS, Z
seconds
mins, f
mins, w
.60
STATUS, Z
mins
hours, f
hours, w
.24
STATUS, Z
hours
; Preload TMR1 register pair
; for 1 second overflow
; Configure for external clock,
; Asynchronous operation, external oscillator
; Initialize timekeeping registers
RTCisr
BANKSEL
MOVLW
MOVWF
CLRF
MOVLW
MOVWF
CLRF
CLRF
MOVLW
MOVWF
BANKSEL
BSF
RETURN
BANKSEL
BSF
BCF
INCF
MOVF
SUBLW
BTFSS
RETURN
CLRF
INCF
MOVF
SUBLW
BTFSS
RETURN
CLRF
INCF
MOVF
SUBLW
BTFSS
RETURN
CLRF
RETURN
; Enable Timer1 interrupt
; Preload for 1 sec overflow
; Clear interrupt flag
; Increment seconds
;
;
;
;
60 seconds elapsed?
No, done
Clear seconds
Increment minutes
;
;
;
;
60 seconds elapsed?
No, done
Clear minutes
Increment hours
;
;
;
;
24 hours elapsed?
No, done
Clear hours
Done
DS30498C-page 82
2004 Microchip Technology Inc.