Netduino home hardware projects downloads community

Jump to content


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.
Photo

New Haven OLED 10-bit SPI Command


Best Answer Mario Vernari, 24 December 2013 - 04:29 AM

The Netduino (Plus) 2 cannot manage SPI-data sized other than 8 or 16 bits.

I suggest to follow (or take inspiration) from the article I have written a while ago. I used a trick to achieve a non-standard data size, yet yielding pretty decent performance.

http://tinyclr.it/su...r-netduino.aspx

Have a nice Christmas!

Go to the full post


  • Please log in to reply
2 replies to this topic

#1 garethconner

garethconner

    New Member

  • Members
  • Pip
  • 2 posts

Posted 23 December 2013 - 07:48 PM

Hi folks,

 

I'm spending my first "real" day with the Netduino 2 Plus.  I've got a 4x20 OLED character display from New Haven (NHD-0420DZW-AY5).  This is a similar display to ones we use in some of our products with Rabbit micros.  In other products we use these displays in 8-bit parallel mode and hang them on the Rabbit data bus, but I'm trying to conserve pins on my Netduino so I thought I could re-configure the display for SPI as per the data sheet.

 

My difficulty is that the the command words for the display are 10-bits wide (RS, RW, D7..D0).  I'm a little foggy about how to send a 10-bit word via the SPI class.  It looks like there is an overload for SPI#WriteRead that accepts a writeOffset & writeCount, so I thought perhaps I could hand it a 16-bit value with an writeOffset=0 and a writeCount=10.  This is a code snippet:

        public static void InitOLED()        {            UInt16[] readBuffer = new UInt16[1];            var config = new SPI.Configuration(Pins.GPIO_PIN_A4,                 false,                150,                150,                true,                true,                ((1/3) * 10000),                SPI_Devices.SPI1                );            _oled = new SPI(config);            Thread.Sleep(100);            //Display OFF            _oled.WriteRead(new UInt16[] { 0x08 }, 0, 10, readBuffer, 0, 8, 0);

When run, the last line that contains the WriteRead call generates the following exception:

An unhandled exception of type 'System.ArgumentException' occurred in Microsoft.SPOT.Hardware.dll

I'm clearly doing something silly, but can't see what I've done wrong.  Any help would be greatly appreciated.  Thanks!



#2 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 24 December 2013 - 04:29 AM   Best Answer

The Netduino (Plus) 2 cannot manage SPI-data sized other than 8 or 16 bits.

I suggest to follow (or take inspiration) from the article I have written a while ago. I used a trick to achieve a non-standard data size, yet yielding pretty decent performance.

http://tinyclr.it/su...r-netduino.aspx

Have a nice Christmas!


Biggest fault of Netduino? It runs by electricity.

#3 garethconner

garethconner

    New Member

  • Members
  • Pip
  • 2 posts

Posted 26 December 2013 - 06:46 PM

Hi Mario,

 

Thanks very much for you answer.  That is a very clever solution.  I may steal back some the io pins with an io expander and revert to a 4-bit parallel interface for the display.  However, it's good to see that the 10-bit SPI protocol is possible with some hacking.

 

Merry Christmas (belated) and happy New Year!






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

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.