Page 1 of 1

Timer with LCD

Posted: Mon Apr 18, 2011 4:24 pm
by cam
Hello,

I am trying to make an accurate timer with tenths of seconds. I am using TMR2 to produce a 50hz interrupt, and using a count to 10 in the interrupt to increment the tenths of seconds. I need to display the time on an LCD.
I have a flag variable in the interrupt that tells the main program to update the LCD. My question is, how can I update the LCD without disabling TMR2 before and after? Disabling the interrupt causes the timer to loose accuracy.

Thank you

Re: Timer with LCD

Posted: Mon Apr 18, 2011 4:40 pm
by medelec35
What I would do is when I want the LCD to update e.g every 10th of a second , then set update flag within timer interrupt to 1
In Main have a loop, and within that loop a decision branch if update = 1 then display new time : set update to 0
You will not need to disable timer to do this since Loop within main will be accessed much faster than interrupt.

Martin