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
Timer with LCD
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Timer with LCD
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
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
Martin