Maybe this will help ...
http://www.picbasic.co.uk/forum/show...7079#post47079
<br>
Hi,
Trying out the "Elapsed Timer" I am observing these issues:
Beeing that I don't have an LCD module, I am trying to write the values in EEPROM and then read back using a PICKit2.
I know the code is working because LED1 is blinking and the rate seems to be good.
My first write is succesful
then trying to write the value for "Seconds" is always 00
trying to write the value for Minutes is always FF (even after a few minutes)
Am I missing something?Code:INCLUDE "DT_INTS-14.bas" INCLUDE "ReEnterPBP.bas" INCLUDE "Elapsed_INT.bas" ; Elapsed Timer Routines LED1 var portc.0 ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler TMR1_INT, _ClockCount, PBP, yes endm INT_CREATE ; Creates the interrupt processor INT_ENABLE TMR1_INT ; Enable Timer 1 Interrupts ENDASM GOSUB ResetTime ' Reset Time to 0d-00:00:00.00 GOSUB StartTimer ' Start the Elapsed Timer write 5,3 ; this is working fine. Main: IF SecondsChanged = 1 THEN SecondsChanged = 0 toggle led1 T1CON.0 = 0 write 0,Minutes ; this is always showing 00 write 1,Seconds ; this is always showing FF 'LCDOUT $FE,2, DEC Days,"d-",DEC2 Hours,":",DEC2 Minutes,":",DEC2 Seconds ENDIF GOTO Main
Thanks
Mike
The T1CON.0 = 0 line is turning off the Timer.
So it never counts again.
At the start of the program, the SecondsChanged bit is set so that programs will display the initial 00:00:00.
So it stops counting before the first second passes.
<br>
DT
Some days I feel dumber than others and today is one of those!
I tried joining this code with my code and things are not going so well... I have a piezo beeping on the press of the swithes and when I added this code it is more like rigning than beeping and also I have a feeling I need something short and simple but I am trying to use something big and complex.
All I really need is to have a counter that counts the minutes up to 720 and then cycle to 0 and start over endlessly. I don't need an interupt as I can test compare by branching from the main loop (in one minute I have plenty of time to test) Accuracy is not really important + or - 10 minutes over 720 is ok. I am already using timer0 so I guess I need to use timer1 or timer2.
Do you have any simple and quick advice or link to suggest?
I feel I have taked already too much of your time and I apologize for that.
Mike
Hi Mike,
Welcome to My World!
A great clock this will not be, it does (should do) what you asked, you may need to juggle the numbers if you have a bunch of code to stuff in.Code:counter var byte minutes var word clear ' zero variables at start loop: PortB = %00000000 TRISB = %00000000 counter = counter + 1 Pause 1000 If counter >= 60 then minutes = minutes + 1 : counter = 0 if minutes >= 720 then gosub action goto loop Action: minutes = 0 Toggle PortB.1 ' change this to do what you need done return
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Well, that in itself implies there are days when you don't feel that way ...
Only prior instances of feeling "Smart" can make you recognize the "dumb" when it comes around.
Let's see if we can't make tomorrow a little better.
At first I was trying to make it easy with an example Without Interrupts.
Then you found my interrupt program, and the Elapsed Timer.
Combining the two has no doubt created the headaches.
I've tried to figure out what you were doing from the previous posts, and failed.
If I could see what you had so far, I might be able to combine things using only DT_INTS.
Who knows?
<br>
DT
Bookmarks