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

LCD4884 DFRobot shield SPI interface


  • Please log in to reply
2 replies to this topic

#1 Harley Mackenzie

Harley Mackenzie

    New Member

  • Members
  • Pip
  • 1 posts

Posted 20 December 2011 - 12:40 AM

I am trying to use a DFROBOT DFR0092 arduino shield that has a graphic LCD 4884 display. My problems are with the SPI interface and I have referred to the NetduinoNokia3310 Netduino shield code that has certainly helped me get to this point.

My issue is that the Ardunio library code defines all of the pins that the shield uses in the LCD4884.h header file:

#define SPI_SCK 2
#define SPI_MOSI 3
#define LCD_DC  4
#define SPI_CS  5
#define LCD_RST 6
#define LCD_BL  7  

and the code for the .Net framework modified from the Nokia shield code is then:

  public SPI.Configuration conf;
  public SPI SPI_port;
  public OutputPort RST = new OutputPort(Pins.GPIO_PIN_D6, false);
  public OutputPort DC = new OutputPort(Pins.GPIO_PIN_D4, false);
  public OutputPort BL = new OutputPort(Pins.GPIO_PIN_D7, false);

  public LCD4884() {
    init();
  }

  public void init() {
    conf = new SPI.Configuration(Pins.GPIO_PIN_D5, false, 0, 0, false, true, 1000, SPI.SPI_module.SPI1);
    SPI_port = new SPI(conf);

I do not understand where in the Netduino code using the SPI class that I define the shield assigned pin 2 -> SPI_SCK and pin 3 -> SPI_MOSI that I believe are the clock and data lines for the SPI interface?

Is there an assumption about the pins that are used for these lines and these cant be changed to match the shield design?

I am not an expert in SPI and just starting with the netduino so ANY help very much appreciated.

Harley

#2 teo

teo

    Member

  • Members
  • PipPip
  • 12 posts
  • LocationEdmonton, AB

Posted 24 December 2011 - 12:55 AM

Hi, I am switching to netduino now and I have the same problem with that shield. The SPI pins of that shield (pins 2,3) are not the same as the ones arduino/netduino have. In the netduino, the hardware SPI pins are at digital pins 11,12,13. If you own a netduino plus, the second SPI port is taken up by the SD card. In my humble opinion, one way to fix this is to bit-bang pins 2, 3 and the other control pins for the lcd to achieve some "software SPI". But that may be a headache since if the lcd still doesn't work, you don't really know whether the software SPI is implemented wrongly or the lcd configuration is wrong (not sure if that DFR lcd = nokia3310). Got to do it carefully. For a start, I'm going to look out for some good software SPI codes out there.

#3 teo

teo

    Member

  • Members
  • PipPip
  • 12 posts
  • LocationEdmonton, AB

Posted 24 December 2011 - 03:52 AM

Hi,

I have found a solution for the problem (not perfect, but works).

There is a column of pads on the bottom-left corner of the LCD. Connect "SCLK" to Pin13 and "SDIN" to Pin11. Optionally, you can connect digital pin 10 to "BL_ON". These pins are easily accessible from the built-in rc servo connectors.

Then, use the driver found here:
http://wiki.netduino...hx?NoRedirect=1
(I didn't try the 3310 driver you mentioned)

Next, make these two changes:

// From "Program.cs":
Nokia_5110 Lcd = new Nokia_5110(true, Pins.GPIO_PIN_D10, Pins.GPIO_PIN_D9, Pins.GPIO_PIN_D7, Pins.GPIO_PIN_D8);
// Change to:
Nokia_5110 Lcd = new Nokia_5110(false, Pins.GPIO_PIN_D5, Pins.GPIO_PIN_D7, Pins.GPIO_PIN_D6, Pins.GPIO_PIN_D4);
// If pin 10 is connected to "BL_ON", then change to:
Nokia_5110 Lcd = new Nokia_5110(true, Pins.GPIO_PIN_D5, Pins.GPIO_PIN_D10, Pins.GPIO_PIN_D6, Pins.GPIO_PIN_D4);
Why: To match the DFR lcd pin out.


// From initialisation line of "Nokia.cs":
spi.Write(new byte[] { 0x21, 0xBF, 0x04, 0x14, 0x0C, 0x20, 0x0C });
// Change to:
spi.Write(new byte[] { 0x21, 0xc0, 0x06, 0x13, 0x20, 0x0c });
Why: Frankly, I do not know *why* .. I just followed the initialisation procedure from the original Arduino driver (LCD4884.cpp). If you are curious, you may want to check the datasheet of the LCD driver. If you skip this change, the contrast of the display will be very poor.


Some notes:
-(updated)If you find that there are some artefacts on the screen, you may need to reduce the SPI clock from 4000kHz to 1000kHz. I found that 1000kHz worked better for me.
-The "useBacklight" parameter must be set to "false" as the DFR LCD's backlight pin is digital pin 7 (not a PWM pin). You can still switch it on and off, but you cannot dim it by the PWM hardware. However, I have connected digital pin 10 to the "BL_ON" pad of the LCD so that I can still use the PWM functionality.
-The drawback of this method is that digital pins 2,3 (the former CLK and MOSI lines) are no longer usable as GPIO pins since they are now electrically connected to pins 13,11, respectively. You will further waste digital pin 7 (the former backlight pin) if you have connected digital pin 10 to "BL_ON".




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.