3595i LCD – First Signs of Life
Even a small success is a success. I have for the first time seen a reaction from the LCD screen I pulled out of my nokia 3595i. Although I had some code on hand from other Internet sources I couldn’t get any response from the screen. Please forgive this photo, I don’t have a suitable back light set up for this display so you see an LED filtered by a piece of paper behind the display.
I made progress because I was able to get a hold of the datasheet for controller this screen uses. It was linked to at one of my favorite tech blogs, Embedded Projects From Around the Web. Their post was a review of a project that connected LCD screen from a Nokia 3510i to a pic16f84. The code there is in assembly and I’m not able to make much sense out of that language.
I will continue to develop a library for interfacing an ATtiny2313 with this display. Look for more as I make progress. To wet your appetite, here’s the source code that provides the output you see in the picture above:
#define F_CPU 1000000UL
#include <avr/io.h>
#include <util/delay.h>
#define LCD_PORT PORTB
#define LCD_DDR DDRB
#define LCD_CLK (1<<PB0)
#define LCD_SIO (1<<PB1)
#define LCD_CS (1<<PB2)
#define csh LCD_PORT |= LCD_CS
//LCD_Out function comes from source code found here:
//http://hobbyelektronik.org/Elo/AVR/3510i/index.htm
//Unfortunately this is the only way I know to attribute
//this code to the writer.
void LCD_Out(unsigned char Data, unsigned char isCmd) {
if(isCmd) LCD_PORT |= LCD_CS;
LCD_PORT &= ~(LCD_CLK|LCD_CS); //Clock and CS low
LCD_PORT |= LCD_SIO; //SData High
if(isCmd) LCD_PORT &= ~LCD_SIO; //If it is a command, SData Low
LCD_PORT |= LCD_CLK; //Clock High
for(char x=0; x<8; x++) {
LCD_PORT &= ~(LCD_SIO|LCD_CLK); //Clock and SData low
if(Data & 128) LCD_PORT |= LCD_SIO; // Mask MSB - SData high if it is a 1
LCD_PORT |= LCD_CLK; //Clock High
Data=Data<<1; //Shift bits 1 left (new MSB to be read)
}
}
void LCD_init(void)
{
LCD_DDR |= (LCD_CLK | LCD_SIO | LCD_CS);
LCD_PORT |= (LCD_CLK | LCD_SIO | LCD_CS);
//Software Reset
LCD_Out(0x01, 1);
_delay_ms(10);
csh;
//Booster Voltage On
LCD_Out(0x03, 1);
_delay_ms(50);
csh;
/*
//Test Mode
LCD_Out(0x04, 1);
csh;
*/
//Sleep Out
LCD_Out(0x11, 1);
csh;
//Display mode Normal
LCD_Out(0x13, 1);
csh;
//Display On
LCD_Out(0x29, 1);
csh;
}
int main(void)
{
LCD_init();
while(1)
{
}
}