Hello All,
I recently came into possession of a Nokia 1202 LCD with STE2007 controller (http://www.datasheetdir.com/STE2007+LCD-Drivers-Controllers) so naturally i hooked it up to my arduino uno to see if i could get it to work.
Being my first project with SPI and a proper LCD, it did not work and I cannot figure out why. Points to note ...
- The STE2007 controller works with 3v3 levels so as a makeshift I fed the output of the arduino pins through a simple resistance voltage divider to get 3v3 level from 5v0
- It expects 9 bits (data/control + 8 bit payload) and since SPI is limited to 8 bits I wrote my own manual SPI function
My code is :
#define CS_PIN 10
#define MOSI_PIN 11
#define MISO_PIN 12
#define SCK_PIN 13
#define LCD_RESET_PIN 9
#define LED_PIN 8
#define write_spi_command(x) write_spi(x, 0);
#define write_spi_data(x) write_spi(x, 1);
void setup()
{
//set pin directions
pinMode(CS_PIN, OUTPUT);
pinMode(MOSI_PIN, OUTPUT);
pinMode(MISO_PIN, INPUT);
pinMode(SCK_PIN, OUTPUT);
pinMode(LED_PIN, OUTPUT);
pinMode(LCD_RESET_PIN, OUTPUT);
//disable lcd to start with
digitalWrite(CS_PIN, HIGH);
digitalWrite(MOSI_PIN, LOW);
digitalWrite(SCK_PIN, LOW);
//turn on the led
digitalWrite(LED_PIN, HIGH);
//turn on serial debugging
Serial.begin(9600);
Serial.println("-----NOKIA 1202 LCD DEMO-----");
//start the lcd
LCD_init();
write_spi_data(0xFF);
write_spi_data(0xFF);
write_spi_data(0xFF);
}
void loop()
{
}
int write_spi(byte payload, byte dc)
{
//select lcd
digitalWrite(CS_PIN, LOW);
//write dc bit
if(dc==0){digitalWrite(MOSI_PIN, LOW);}
else {digitalWrite(MOSI_PIN, HIGH);}
digitalWrite(SCK_PIN, HIGH);
digitalWrite(SCK_PIN, LOW);
//write payload 8 bits
for(int i=7;i>=0;i--)
{
digitalWrite(MOSI_PIN, (payload>>i)&1);
//toggle clock
digitalWrite(SCK_PIN, HIGH);
digitalWrite(SCK_PIN, LOW);
}
//turn off lcd cs
digitalWrite(CS_PIN, HIGH);
Serial.print("Written 9 bits ::: ");
Serial.print(dc, HEX);
Serial.println(payload, HEX);
}
void LCD_reset()
{
digitalWrite(LCD_RESET_PIN, LOW);
delay(5);
digitalWrite(LCD_RESET_PIN, HIGH);
delay(5);
Serial.println("\nLCD Hardware Reset Complete");
}
void LCD_init()
{
LCD_reset();
write_spi_command(0xE2); //reset
delay(10);
write_spi_command(0xA4); //power save off
write_spi_command(0x2F); //power control set
write_spi_command(0xB0); //set page address
write_spi_command(0x10); //set col=0 upper 3 bits
write_spi_command(0x00); //set col=0 lower 4 bits
write_spi_command(0xAF); //lcd display on
Serial.println("\nLCD Init Complete");
}
My serial output prints everything okay so i know the functions are getting executed properly yet i dont see anything on the LCD. any ideas? I am not sure at this point if its the display controller initialization that's not right or my SPI function ....
Thank you,
ankit