PDA

View Full Version : Using Pause and TMR0



Pesticida
- 26th August 2007, 08:10
Hi,

I have a little question ?

Did Pause affect the work for TMR0.

I have for Example one Timer that when I Push a Button Displays Hours,Minutes and Seconds.
I have a Interrupt Routine all work fines.

Interrupt:

.............

If Button Press Then Display :-)

Display:
High Led_LCD
Lcdout $fe,$80," Time "
Lcdout $fe,$C0,DEC2 Hour[2],":",DEC2 Minute[2],":",DEC2 Seconds[2]
Pause 5000 ''''''''''''''''Display for 5 Seconds
Low Led_LCD

.............
Did this 5 Seconds affect my TMR0 Interrupt,and I have next Time -5 Second in My Time Display!?

When yes what I can do to not affect My TMR0 Timer.

Thanks a lot!

Regards Pesti

Bruce
- 26th August 2007, 12:57
Did this 5 Seconds affect my TMR0 Interrupt,and I have next Time -5 Second in My Time Display!?
If you're using ON INTERRUPT, then yes. The PAUSE 5000 will definitely affect how long it will
take before your interrupt is serviced. It won't affect TMR0 counting. Only the time before
your interrupt gets serviced.


When yes what I can do to not affect My TMR0 Timer.
Use assembler interrupts. Look for Darrel Taylors' interrupt routines here.

Pesticida
- 26th August 2007, 19:07
Thank You Bruce !

Regards Pesti.

Pesticida
- 26th August 2007, 20:59
Hi,

I Found another Way.

When I use for Example this:
Display:
Lcdout ..........................
Pause 5000
LCDout..........................
Pause 4000
Resume
------------------------------------------------------------------------
Seconds = Seconds + 9 ' Add 9 Seconds to Seconds Variable
Then I add in My Second Variable the Seconds that I have Lost with my pause statment.
Is This a good Idea?

Regards Pesti

Pesticida
- 26th August 2007, 21:34
I add a new Code line:

Timer:
TMR0IF = 0 '''''''''''''''''''''''''''''''''''''''''''''Clear Timer 0 Interrupt
TMR0H = $0B
TMR0L = $DB
Second[2] = Second[2] + 1

I add next Line
If Second[2] > 60 Then Second[2] = Second[2] - 60 : Minute[2] = Minute[2] + 1

If Second[2] = 60 Then Minute[2] = Minute[2] + 1 :Second[2] = 0
If Minute[2] >= 60 Then Hour[2] = Hour[2] + 1 :Minute[2] = 0
If Hour[2] >= 24 Then Hour[2] = 0

Regards Pesti

Bruce
- 26th August 2007, 21:37
Hi Pesti,

If it works for your application, then go for it...;o}

I can't see where it would hurt. Remember, however, that you have a time period that's not
accounted for during each LCDOUT sequence. If this missing time isn't a problem, then just
go with what you have.

If timing is critical, you could always find out how long each LCDOUT takes, and factor this
into your PAUSE time using PAUSEUS.

See this thread for details http://www.picbasic.co.uk/forum/showthread.php?t=365