Nokia 3310 was an extremely popular mobile phone during it’s time. However with advent of newer colour mobile phones the old ones are discarded, but almost everyone possessed this magical phone. As the topic suggests we are going to interface a Nokia 3310 LCD (Type LPH7779) with a PIC18F2520. The LCD can be bought at any mobile repairing shop or can be hacked off an old Nokia 3310. Beware the Chinese LCD do not possess the entire pixels but still work pretty well if you cannot find the original. The LCD is based on PCD8544 controller, it can drive a 48X84 pixels matrix LCD. Please note that this type of LCD interfacing is different than the conventional HD44780 type LCD. The LPH7779 LCD displays pixels and the characters need to be first created in the PIC Micro Memory, unlike the 2X16 LCD where the characters can be directly printed on the screen.
The tutorial is aimed at providing basic information for beginners and does not include the complex character generation method used. However any advanced user may read the datasheet for the controller and understand the method of displaying character and other commands used to initialize the LCD.
The compiler used is MikroC from Mikroelektronika (www.mikroe.com) which is available for download with 2k demo limit.
The LCD connects with PIC 18F2520 via SPI (Serial Peripheral Interface) and requires only 5 I/O lines. The setup uses the internal RC oscillator of PIC micro and no external crystal is required. The setting for internal RC oscillator can be set in the CONFIG register during setting up a new project wizard of MikroC. Inexperienced users may utilize an external 4 MHz crystal.
LCD PIN Details
- SDIN: Serial Data Input
- SCE: Chip Enable
- SCLK: Serial Clock
- D/C: Data or Command
- Reset: Reset’s Chip
- VDD: 3V Supply
- Vout should be connected to GND via a 4.7uF (or higher) value capacitor.
Note: The VDD & VSS pins of PIC 18F2520(not shown) should be connected with VDD & GND of power supply or battery. A 100nf capacitor should be connected between the VDD& VSS pins of PIC18F2520. The circuit should operate at 3 volts, a CR2032 lithium ion cell may be used. The circuit consumes very low power.
A Microchip ICD2 is used for programming. The picture shows a 18F2520 running a Nokia 3310 LCD. The setup may seem a little crude, but you can do the pruning and making it look a little pretty.
Program:
/* Nokia 3310 LCD Interfacing
BOTSKOOL
SHOBHITKUKRETI
*/
#include<nokia3310botskool.h>
#include<all.h>
void main()
{
TRISC=0; // PORT C as output
PORTC=0; // Intial Value at PORTC is Zero
cmcon=0x07; // Turn off the comparators
nokia_init(); // Initialising the Nokia LCD
delay_ms(10);
nokia_clear_screen(); // Screen should always be cleared intially.
delay_ms(10);
nokia_clean_ddram();
while(1)
{
nokia_gotoxy(15,0);
printf(" BOTSKOOL");
nokia_gotoxy(15,1);
printf(" CAN BE");
nokia_gotoxy(15,2);
printf(" REAL");
nokia_gotoxy(15,3);
printf(" FUN ");
nokia_gotoxy(15,4);
printf(" 24/7 ");
delay_ms(1500);
nokia_clean_ddram();
nokia_gotoxy(0,0);
printf("MADE");
nokia_gotoxy(40,0);
printf("BY");
nokia_gotoxy(5,2);
printf("SHOBHIT");
nokia_gotoxy(5,3);
printf("KUKRETI");
delay_ms(1500);
nokia_clean_ddram();
}
}
Please place the two header files in the include folder of “C:/Program Files/Mikroelektronia/MikroC” before compiling the code.
Comments & Suggestions are welcome.
P.S. : -
LCD Controller is PCD8544, google it for datasheet and understanding the various commands sent to LCD to initialize. It also provides a good example to show how fonts can be developed. To display a picture on this LCD, small program called FAST LCD may be used which will covert any bmp image into a table which needs to be fed to the microcontroller. Similar to character generation the picture is first created in the PIC Micro memory and then displayed on the LCD
ไม่มีความคิดเห็น:
แสดงความคิดเห็น