[sdiy] LCDs, encoders, and interrupts

Stewart Pye stewpye at optusnet.com.au
Sat Feb 27 12:07:27 CET 2010


Hi Tom,

The easy way would be to disable the interrupt while transferring data 
to the LCD. After writing data to the LCD you could set the timer to a 
value so that the interrupt will be triggered.

Or maybe something like this...

Set a busy flag while you are transferring data to the LCD. At the 
beginning of the encoder ISR check if the busy flag is set, and exit if 
it is. You could set another flag to indicate that the interrupt has 
been triggered (or if you can exit the ISR without clearing the IRQ flag 
just use the IRQ flag). When you have finished sending data to the LCD 
check the IRQ flag and if it is set execute the ISR, perhaps resetting 
the timer so the the next ISR happens at the normal interval.

Regards,
Stewart


Tom Wiltshire wrote:
> 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
>
>
>
> _______________________________________________
> Synth-diy mailing list
> Synth-diy at dropmix.xs4all.nl
> http://dropmix.xs4all.nl/mailman/listinfo/synth-diy
>




More information about the Synth-diy mailing list