Timer with LCD

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
cam
Posts: 3
Joined: Sat Apr 16, 2011 3:17 am
Contact:

Timer with LCD

Post 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

medelec35
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

Post 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
Martin

Post Reply