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).

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).

Your delay loop isn't written correctly. Try dry running it on paper and you should see what's wrong with it. Remember decfsz means decrement and skip the next instruction if zero, so if the dec doesn't set it to zero it'll do the goto, and if it does it'll jump to the next decfsz.

Compare with the following code taken from one of the Velleman kit K8048 examples:

There's an inner loop and an outer loop. For your solution you'll need four nested loops.

> the program should be running every five minutes

Don't mean to nitpick but if this is the case the delay should be 2.5 minutes, not 5 minutes. Or do you mean the program should toggle the state of PortB.0 every five minutes?

How accurate does it need to be? If it needs to be exactly every five minutes without any kind of drift (apart from thermal) then you'll need to take the exact RC time into account, the time to do the bsf/bcf and the time to call a subroutine.

-Its doesn't need to be that exact since I will not be displaying the time (time is more difficult to be done in PIC),, we only chose five minutes as minimum for short time presentation in defense. The program will be the basis for the motors operation. Since our motor is a motor to of a washing machine its not ideal to be seconds or a minute delay.. It is most appropriate if we could to the delay for hours, but goodness we cannot even produce a good delay.

-Somehow I notice that there something wrong with the program, but I couldn't pinpoint. I am not good in assembly. I'm still learning it by now.

-Thanks for the codes... I'll try to figure it out..

-hehe I'll be frank,, know what I been doing the thinking of the program for quiet sometime, but I end up knowing it as if for the first time.. as in worst.. to think that we are running out of time.. (a hateful act)

-Thanks again..

[QUOTE=xpi0t0s]Your delay loop isn't written correctly. Try dry running it on paper and you should see what's wrong with it. Remember decfsz means decrement and skip the next instruction if zero, so if the dec doesn't set it to zero it'll do the goto, and if it does it'll jump to the next decfsz.