Searching \ for 'Timer1 interrupts interfere with LCD' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ints.htm?key=interrupt
Search entire site for: 'Timer1 interrupts interfere with LCD'.

Truncated match.
PICList Thread
'Timer1 interrupts interfere with LCD'
2002\12\17@121247 by Larry Bradley

flavicon
face
More playing about with timers. I was using timer1 with a 32768 xtal,
interrupting every  second. Xtal was running slow.

So I decided to try using timer1 driven from the internal osc (20mHz xtal
on a '877). Figured out how to load the timer in the interrupt routine
without screwing up the time interval. Now I get one interrupt every 10
milliseconds, and can keep track of time of day.

My problem:
I'm displaying the time on an LCD - the code uses bit-banging to do the
output. (I'm using PicBasic Pro, so I didn't code the LCD stuff myself).
Every once in a while the display hiccups - presumably because the timer
interrupt routine went off in the middle of sending data to the LCD, and
disrupted the timing. Same thing happens if I send the output via
bit-banging serial output (again in PicBasic Pro)

I presume that I could disable interrupts before doing the I/O, and turn
them on after. In this case, I think that the timer1 counter would contain
a number equal to the number of instruction cycles taken by the LCD
routine. Since I have to preload the counter in the interrupt routine
anyhow, in order to get an interrupt every 10 msecs, I think I can compute
a new preload based on the existing counter, so the next timer cycle will
be shorter, to compensate for the time lost in the LCD routine.

This is my first time experimenting with timers and interrupts. Is what I'm
proposing a good way to do this? Anyone got any better ideas?

Thanks


Larry Bradley
Orleans (Ottawa), Ontario, CANADA

--
http://www.piclist.com hint: To leave the PICList
spam_OUTpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu>

2002\12\17@162454 by Dominic Stratten

flavicon
face
I had a similar problem - turned out to be occasionally interrupting when it
was in page bank 1 - took me ages to work it out and debug it. Just save the
current page at the start of the interrupt and put the pic back into
whatever page it was in when the interrupt occurred at the end of the int.
routine.

Dont forget to pop and push the W register (and carry etc) before returning
to the point where the interrupt occurred.

May not be the right answer but worth looking into.

Dom


{Original Message removed}

2002\12\17@183726 by Larry Bradley

flavicon
face
In my interrupt routine, I'm saving W, STATUS and PCLATH, and restoring
them at the end. I thought that was all I needed to save. But I'm no expert
yet.

Larry

At 09:19 PM 12/17/2002 +0000, you wrote:
{Quote hidden}

Larry Bradley
Orleans (Ottawa), Ontario, CANADA

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam@spam@mitvma.mit.edu>

2002\12\17@190919 by Andrew Warren

flavicon
face
"Larry Bradley" <lhbradleyspamKILLspamIGS.NET> wrote:

> I presume that I could disable interrupts before doing the I/O,
> and turn them on after. In this case, I think that the timer1
> counter would contain a number equal to the number of instruction
> cycles taken by the LCD routine. Since I have to preload the
> counter in the interrupt routine anyhow, in order to get an
> interrupt every 10 msecs, I think I can compute a new preload based
> on the existing counter, so the next timer cycle will be shorter,
> to compensate for the time lost in the LCD routine.
>
> This is my first time experimenting with timers and interrupts. Is
> what I'm proposing a good way to do this?

   Yes, that's a good way.  In practice, you "compute a new preload
   based on the existing counter" by replacing your current MOVWF
   TIMER1 with ADDWF TIMER1.

   -Andy

=== Andrew Warren -- .....aiwKILLspamspam.....cypress.com
=== Principal Design Engineer
=== Cypress Semiconductor Corporation
===
=== Opinions expressed above do not
=== necessarily represent those of
=== Cypress Semiconductor Corporation

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspam_OUTspamTakeThisOuTmitvma.mit.edu>

More... (looser matching)
- Last day of these posts
- In 2002 , 2003 only
- Today
- New search...