Extending GPIO 8 bit data to 16 bit data


9 posts
by xtramural » Wed Jul 11, 2012 4:45 pm
I have a 3.2TFT LCD left over from an Arduino-based project that I would like to interface to the Pi. However, this device has a 16-bit data interface and since it's been decades since I do any electronics I would appreciate any advice on the best way to mux/demux the 8 GPIO data pins to a 16 bit interface. I've done a bit of googling and have dug up octal latches/transceivers such as the Buffer/Driver/Transceiver - Registered Transceiver - SN74LVTH543 - TI.com but don't really know if these are what's required or if there are better alternatives.

Has anyone else extended the GPIO bus along these lines?

Cheers,

Duncan
Posts: 104
Joined: Thu Dec 29, 2011 11:16 pm
Location: Scotland
by Gert van Loo » Wed Jul 11, 2012 5:07 pm
Yes, you can use those but it will require a fair amount of bit-bashing.
Nothing which can not be solved with some decent read_word/write_word functions.
There are a lot of other signals besides the 16 data words, so I would go for three of those chips.
Biggest challenge is that you have 6 control lines per 543. You probably do not need all 3x6 = 18 combinations.
Best is to sit down with a piece of paper and draw all the combinations you need. Check if it helps if you
add a single invert chip as it allows you to make a GPIO and a NOT-GPIO at the same time.
You can probably tie all Latch enables from the display side permanent low.
You can control all three OE to the display side with one signal etc.

Tip: use ~1k series resistor between your chips and your PI. Just in case you make a programming error ;) and you have accidentally BOTH outputs (PI and Latch) enabled. It will prevent your Pi GPIO pins from blowing out.
User avatar
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2078
Joined: Tue Aug 02, 2011 7:27 am
by xtramural » Wed Jul 11, 2012 5:19 pm
Gert, thanks for the help/advice. I will abstract away the complexity with bitbanging functions but I wonder if I can set up some of the other GPIO pins as data too to get the extra control lines that'll I'll need in addition to the 16 data lines. I assume so since Raspberry Pi | Wiring | Pins | Gordons Projects managed to hook up 17 of the GPIO pins to LEDs. I.e. it seems the default usage of (some) other GPIO pins can be overridden?
Posts: 104
Joined: Thu Dec 29, 2011 11:16 pm
Location: Scotland
by Gert van Loo » Wed Jul 11, 2012 5:38 pm
You will need to change the GPIO modes often as you have to switch between input (read) and output (write) mode.
Best is to have 8 GPIOs which you use bi-directional. That leaves you 9 for control signals. You might want to reserve one for a final strobe as that makes the coding easier.
Unless you can display data using writes only. That would simplify your set-up a lot.
User avatar
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2078
Joined: Tue Aug 02, 2011 7:27 am
by xtramural » Wed Jul 11, 2012 5:51 pm
In the first instance I'll be updating the display by writing only. This is also an interim solution since I have ordered a couple of similar displays but that have 8-bit data interfaces. These are shipping from China by China Airmail so it may be several weeks before I see them ;)

Time to work out the mappings of data and control that I will need.

Cheers,

Duncan
Posts: 104
Joined: Thu Dec 29, 2011 11:16 pm
Location: Scotland
by gordon@drogon.net » Thu Jul 12, 2012 9:38 am
xtramural wrote:In the first instance I'll be updating the display by writing only. This is also an interim solution since I have ordered a couple of similar displays but that have 8-bit data interfaces. These are shipping from China by China Airmail so it may be several weeks before I see them ;)

Time to work out the mappings of data and control that I will need.

Cheers,

Duncan


Another solution might be to build 16-bits worth of shift-register. You then use just 2 pins on the Pi to serialise the 16-bit value into the displays data buffer, then you'll have a couple more pins to do the enable and strobe function. so I think you can daisy-chain 2 x 74HC595 shift registers together - that'll give you a 16-bit parallel output bus - but it's output only, so no reading back from the display with this method.

It'll also be slower - as you'll be taking (approx.) 16 times the time to clock the data out to the display, however for demonstrations/proof of concept it should work OK.

So I imagine you'd do something like

Code: Select all
cycle
  clock the 16-bit data into the shift-register
  toggle the chip enable pin
  toggle the chip strobe pin
repeat


for each 16-bit's worth of data... (and you might even be able to optimise it further, depending on the way the display needs data clocked into it).

I recently added some shiftOut functions into wiringPi too, but it's 8-bit only, however it can trivially be changed to work in 16-bit mode. wiringPi in native mode can output a "clock" of about 28MHz, so you might even get a speed of 1 word per uS if lucky - that'll be fast enough to draw graphics and load images to the display - fast enough to do amination? Who knows!

If you want to use all the GPIO pins, then unload the i2c and spi drivers from the kernel (if present), and disable the serial port by editing it out of /boot/cmdline.txt and stopping any getty process in /etc/inittab. Then you can use all 17-pins.

If your 8-bit displays are text-based with the Hitachi HD44780U then check:
https://projects.drogon.net/more-in-wiringpi/

if they are the graphical types, then keep watching that space as I have an old graphical LCD based on the KS0108B interface which I'm keen to get going soon.

-Gordon
--
Gordons projects: https://projects.drogon.net/
User avatar
Posts: 1540
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
by xtramural » Thu Jul 12, 2012 9:58 am
Gordon, many thanks for the help and advice.

I think I will go the shift register route in the interim.

The 8-bit (graphic) display is a 2.8" version of the 3.2" display. The controller of this LCD module is ILI9325DS: it has an 8bit data interface with 4 wires control interface. So once this arrives I should get a major performance boost for my application.

Cheers,

Duncan
Posts: 104
Joined: Thu Dec 29, 2011 11:16 pm
Location: Scotland
by gordon@drogon.net » Thu Jul 12, 2012 10:09 am
xtramural wrote:Gordon, many thanks for the help and advice.

I think I will go the shift register route in the interim.

The 8-bit (graphic) display is a 2.8" version of the 3.2" display. The controller of this LCD module is ILI9325DS: it has an 8bit data interface with 4 wires control interface. So once this arrives I should get a major performance boost for my application.

Cheers,

Duncan


That display also has an SPI interface... I might be tempted to use that and really reduce the pin-count for the interface...

-Gordon
--
Gordons projects: https://projects.drogon.net/
User avatar
Posts: 1540
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
by xtramural » Thu Jul 12, 2012 10:33 am
gordon@drogon.net wrote:
That display also has an SPI interface... I might be tempted to use that and really reduce the pin-count for the interface...

-Gordon

Yes, but AFAICT it'll not be possible to override the hard-wired settings on the module (without major hacks to the PCB). So, although the LCD controller has that capability, I don't think I can override it programmatically (or get access to its SPI interface through its header).

Thanks for the suggestion anyway.
Posts: 104
Joined: Thu Dec 29, 2011 11:16 pm
Location: Scotland