Netduino home hardware projects downloads community

Jump to content

The Netduino forums have been replaced by new forums at This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.


Member Since 03 Sep 2010
Offline Last Active Feb 22 2011 07:59 AM

Topics I've Started

Using SPI to drive 8-bit parallel LCD via shift registers

15 November 2010 - 09:46 PM

Here's a small project I have been working on to drive an LM6029 LCD display (128x64 @ 2 bits per pixel) using two 74HC595 8-bit shift registers daisy-chained to give 16-bit output. The display requires 8 data lines and a minimum of 3 control lines. Using the shift registers reduces the number of pins required from the netduino to 3. The code also implements a simple text interface for rendering 8x8 text characters using an embedded font. The drawing rate is quite low at the moment (about 2 seconds to fill a screen), which mainly has to do with the fact that an interop. call (SPI.Write) is done for every character. This seems to be necessary to force the CS line to toggle in order for the shift register to latch the output. I'm currently looking at workarounds to be able to blast a whole array of data to the display in one call but the only solution may be to resort to a native-code implementation (I'm still struggling to get the vanilla firmware to compile so it may take a while). There's also one minor optimization which could still be done, and that's to set the display into continuous write mode (aka Read-Modify-Write) which will reduce the number of instructions sent to the display by about a third to a half. Do with it what you will :D

How to write array with SPI

14 November 2010 - 02:39 PM


I'm using SPI to drive a two 8-bit shift registers (74HC595) which in turn drive an LCD display (LM6029). The output loop seems a bit slow because the code needs to call spi.Write once for each output, eg:

           SPI.Configuration config = new SPI.Configuration(

            spi = new SPI(config);
            ushort[] d = new ushort[1];

            for (int i = 0; i < this.bufferSize; i++)
                d[0] = buffer[i];


It seems it would be more efficient to be able to write the buffer array with one call to spi.Write and the method seems to be able to support it as it takes an array as the parameter, eg:


Running the latter seems to result in only the last element of the array being output instead of all the elements being output sequentially.

I have compared this to Szymon's code here and he also calls write() once for each output instead of sending an array.

I'm just wondering what the the difference is between calling write with an array with one element in it, compared to calling write with an array of multiple values. I imagine calling write with one value multiple times would behave the same as calling write once but with multiple values.

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.