Skip to content

2.2″ LCD Continued

February 28, 2014

Well, it didn’t work first time out and a little think showed me why: I need to change the pin numbers for the olduino – Bit 0 of the olduino output port lines up with pin 3 of the arduino.

#define LCD_WR    4-3   //clock
#define LCD_RS    3-3   //data/mosi
#define LCD_DC    6-3   //data/command
#define LCD_REST  5-3   //RESET
#define LCD_CS    7-3   //slave select

Still no reaction but i had the logic analyzer ready and that showed the problem right off.
14-02-27 saleae-1
The general flow of signals looks fine reset, slave select, data/command, clock in groups of 8 all look good but mosi is always showing 0 or 255 which isn’t right. Looking at the spi output routine the reason is obvious, I forgot the shift statement! Easily fixed.

void LCD_Writ_Bus(unsigned char value){
  int i;
  digitalWrite(LCD_CS,LOW);
  for(i=0;i<8;i++){
    digitalWrite(LCD_RS,(value&0x80));      //by setting mosi for each bit
    digitalWrite(LCD_WR,HIGH);              //then pulsing the clock
    digitalWrite(LCD_WR,LOW);
    value<<=1; //next bit
  }
  digitalWrite(LCD_CS,HIGH);
}

Now the spi stream looks correct.  You can see the first command sequence from the beginning of LCD_init.
14-02-27 saleae-2

 

I’m also getting a reaction to the code – the backlight goes out immediately after running the it.  A bit of binary search with a Q loop shows that it’s the second to last line in LCD_init that turns it off (ironically the comment says “display on”.

I’m going to move the lcd to the arduino and see if it goes off momentarily at the same spot. You know what, it does. It’s not completely dark but definitely much duller. Back to olduino.

Hah – it is actually working, it’s just desperate slow! It takes it about 10 seconds to do each of 320 lines – I didn’t believe my 3200 second guess but there you go.14-02-28 magenta
Just to complete the math, it takes 10 sec/480 writes(don’t know why 480 rather than 240 but whatever). so each write is 10000/480 ms or about 20 ms or about 2000 instructions! Next step is to bring that in line.

Advertisements

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: