[sdiy] LCDs, encoders, and interrupts

Tom Wiltshire tom at electricdruid.net
Sat Feb 27 16:18:16 CET 2010


Thanks all. Three different, but equally workable, ideas. This list  
is great.

Cheers,
Tom

On 27 Feb 2010, at 11:39, Colin f wrote:

>
>> -----Original Message-----
>> From: synth-diy-bounces at dropmix.xs4all.nl
>> [mailto:synth-diy-bounces at dropmix.xs4all.nl] On Behalf Of Tom
>> Wiltshire
>> Sent: 27 February 2010 10:28
>> To: synth-diy DIY
>> Subject: [sdiy] LCDs, encoders, and interrupts
>
>> 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.
>
> One solution, if you have the spare RAM, is to buffer writes to the  
> LCD.
> Have the main program write LCD data to the RAM buffer, then the  
> interrupt
> routine that scans the encoder also checks the LCD buffer for  
> changes, and
> incrementally updates the LCD.
> This gives no conflict, and also greatly speeds up LCD access,  
> since you
> only make slow writes for data that has actually changed.
> It can make your main code section much more responsive.
> If you use a count variable to regulate the writing of bytes to the  
> LCD, you
> can ensure each LCD write is complete before the next one is  
> attempted, so
> you don't even have to check the LCDs busy flag.
>
> Cheers,
> Colin f
>
>
> _______________________________________________
> 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