View Single Post
Newbie Member
31Aug2008,06:16  
jn8b's Avatar
-thanks.. the program should be running every fives minutes. Yeah, it sounds difficult.

-Can you please check this program? What's seemed to be wrong in it?

Code:
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _RC_OSC

d1	equ	0x0D
d2	equ	0x0E
d3	equ	0x0F
d4	equ	0x10

	org	0X000
	goto	Init

	org	0X004
	retfie


Init	bsf	STATUS,RP0
	clrf	TRISB
	clrf	TRISA
	bcf	STATUS,RP0

	clrf	PORTA	
	clrf	PORTB

Main	bsf	PORTB,0
	call	Del5M
	bcf	PORTB,0
	call	Del5M
	goto	Main

Del5M	movlw	0x54
	movwf	d1
	movlw	0xA1
	movwf	d2
	movlw	0xFD
	movwf	d3
	movlw	0x02
	movwf	d4
Delay_0
	decfsz	d1, f
	goto	$+2
	decfsz	d2, f
	goto	$+2
	decfsz	d3, f
	goto	$+2
	decfsz	d4, f
	goto	Delay_0

			;5 cycles
	goto	$+1
	goto	$+1
	nop
	return

	end
-In anyway thanks a lot.

Quote:
Originally Posted by xpi0t0s
Probably best to set a timer with interrupt, then you can count the number of times the interrupt goes off. Or if you have an external real time clock it might have the functionality to interrupt you at a given time. Or if you just want to count off five minutes, write a counter subroutine, work out how long one iteration takes (remembering to take EVERYTHING into account - branches taking longer if they branch than if they don't, allowing for any interrupts etc (this also depends on how accurate you want to be)), then just count for the appropriate number of iterations to pass five minutes. So if your loop takes 100ns to count to 1, then 5 min=5*60*10,000,000=300,000,000. Count to 300 million and you're done. If you want to run something every five minutes then the counter approach will throw you off eventually unless you count all the instructions in your program (very tedious).