From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Simon Clubley Newsgroups: comp.lang.ada Subject: Re: Cleanest Ada way to do this? Date: Mon, 23 Jun 2014 11:57:39 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: <7eaee5fc-2045-4bb3-8b16-d757b54760da@googlegroups.com> <623dacba-5886-4b16-8694-950e7cc5a626@googlegroups.com> Injection-Date: Mon, 23 Jun 2014 11:57:39 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="e458ff8b81bc0c159989eb0e36c6e372"; logging-data="5814"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+GQimT0bJqWUNil7mtpjHVY7ZeRM4YkS8=" User-Agent: slrn/0.9.8.1 (VMS/Multinet) Cancel-Lock: sha1:ob2IPFGB8k/3F8LCeBO/414kidw= Xref: news.eternal-september.org comp.lang.ada:20554 Date: 2014-06-23T11:57:39+00:00 List-Id: On 2014-06-23, rrr.eee.27@gmail.com wrote: > On Sunday, June 22, 2014 6:51:01 PM UTC+2, Mike Silva wrote: >> I'd like some help on the cleanest, or most elegant, way to do this in Ada. I'm writing to an LCD character display, in 4-bit mode, which requires writing an 8 bit character or command value as two 4 bit pieces. The port (a memory address) being written to is 32 bits wide. What I would like to be able to do is some form of this (not valid Ada, I know): Port32(4..7) := Some_Char(4..7); ..twiddle some other control bits.. Port32(4..7) := Some_Char(0..3); ..twiddle some other control bits.. Any thoughts? > > You have to drive not only the four data lines but also some Enable or > RegisterSelect lines (for the standard LCD controller HD44780). Those have to > be written in parallel. the second nibble (other half of the byte) has to > follow with specific timing. I recommend a look on lcd.ads, lcd.adb, and > lcd-wiring.ads from AVR-Ada at > http://sourceforge.net/p/avr-ada/code/ci/master/tree/avr/lcd/. > Dammit. That's something I should have thought to go looking for as well. I see they are also using Character'Pos for the conversion although they are also using a more generic approach of treating each data I/O line in isolation instead of as a related block of 4 contiguous lines. Simon. -- Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP Microsoft: Bringing you 1980s technology to a 21st century world