[sdiy] LCDs, encoders, and interrupts

Tom Wiltshire tom at electricdruid.net
Sat Feb 27 11:27:58 CET 2010


Hi all,

Two or three weeks ago there was a discussion about the best way to  
read encoders and update an LCD display with values. Or that was  
*one* of the things that got talked about, anyway.

I'm actually playing with this on my breadboard now, and I've got a  
question. It was suggested that it would be a good idea to read the  
encoders using an interrupt at a reasonable speed (say 500Hz) and  
then update the LCD in main code loop periodically. That way, no  
encoder tweaks would get missed, and if the LCD skips a few values if  
you turn fast, so what?
The problem I've got is that the encoders and the LCD share a  
databus. This means that the 'read encoder' interrupt can occur  
whilst the LCD is in the middle of trying to update the value -  
indeed, because LCDs are so slow, this is quite likely. I can save  
and restore the state of the databus and control lines to the LCD  
along with other variables going into the interrupt routine, but this  
on its own isn't enough. If I'm halfway through a LCD data transfer,  
it will get screwed up.

What to do? Has anyone else had to think about this? I don't want to  
waste time reinventing the wheel if there's a good solution out there  
already.

Thanks,
Tom






More information about the Synth-diy mailing list