Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

TMR1 : 1 minute count

Status
Not open for further replies.

alamy

New Member
dear all.

how to have a counter that will count for 1 minute...by using TMR1 in pic16f628a
i reer to use an interrupt

previously i use delay a minute from piclist code generator.

here the code fo 1 minute delay

Code:
; Delay = 60 seconds
; Clock frequency = 4 MHz

; Actual delay = 60 seconds = 60000000 cycles
; Error = 0 %

	cblock
	d1
	d2
	d3
	endc

Delay1minute
			;59999994 cycles
	movlw	0x23
	movwf	d1
	movlw	0xCB
	movwf	d2
	movlw	0x83
	movwf	d3
Delay1minute_0
	decfsz	d1, f
	goto	$+2
	decfsz	d2, f
	goto	$+2
	decfsz	d3, f
	goto	Delay1minute_0

			;2 cycles
	goto	$+1

			;4 cycles (including call)
	return

how do i modify thsi code so that it can be use for TMR1

thanks in advance
 
alamy said:
how do i modify thsi code so that it can be use for TMR1

You don't, it's got nothing to do with a timer.

A timer can't give a delay anywhere near a minute, you need to set a timer (personally I find tmr2 is the best to use!) to give regular interrupts, I tend to use 10mS interrupts. The interrupt routine then increments a series of registers, giving a count of seconds, minutes, etc.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top