TMR1 With 12F675

Status
Not open for further replies.

Suraj143

Active Member
What I need is I need to use internal RC OSC (4Mhz) & use 32.768xtal to feed TMR1 input to make a RTC.

Can this be done ?I'm doubt where to put 32.768Xtal?
 
Just connect your crystal between pins 2 and 5 with two capacitors of 68-100pF from each pin to ground.

Mike.
 
This is what I need to do,

Internal Time must run no need to display.
I need to toggle a relay in some time intervals on each day.
I need to do a very low power design.

Whats the perfect way of doing?
 
Last edited:
Yes, you are correct, the crystal goes between pins 4 and 5.

From the data sheet,

So, you can use the sleep instruction to reduce power between second interrupts. The 16F88 data sheet has example code to make a RTC with timer 1.
Code:
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			;

Mike.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…