
- Netduino Forums
- → Viewing Profile: Topics: dragonfly
The Netduino forums have been replaced by new forums at community.wildernesslabs.co.
This site has been preserved for archival purposes only
and the ability to make new accounts or posts has been turned off.
Community Stats
- Group Members
- Active Posts 12
- Profile Views 6033
- Member Title Member
- Age Age Unknown
- Birthday December 25
-
Gender
Male
-
Location
South Africa
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

How to write array with SPI
14 November 2010 - 02:39 PM
Hello
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:
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.
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( Pins.GPIO_PIN_D10, false, 0, 0, false, true, 10, SPI.SPI_module.SPI1); spi = new SPI(config); ushort[] d = new ushort[1]; for (int i = 0; i < this.bufferSize; i++) { d[0] = buffer[i]; spi.Write(d); }
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:
spi.Write(buffer);
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.
- Netduino Forums
- → Viewing Profile: Topics: dragonfly
- Privacy Policy