You are on page 1of 8

Author : Arezki YOUYOU e-mail : arezkiyouyou@gmail.

com
Library : Nokia_3310_5110_Lcd Date : 27/07/2014
Microcontrollers : PIC12F, PIC16F, PIC18F, DSPIC, ARM(STM32)

Nokia 3310 5110 LCD Library


Library for communication with Lcds of Nokia 3310 or 5110 LCD 84x48 (with PCD8544 compliant
controllers)

External dependencies of Nokia 3310 5110 LCD Library


The following variable must be defined in all Description : Example :
projects using Nokia 3310 5110 Library:
extern sfr sbit Nokia_3310_SCLK: Clock sbit Nokia_3310_SCLK at RB0_bit;
extern sfr sbit Nokia_3310_SDA: Data line sbit Nokia_3310_SDA at RB1_bit;
extern sfr sbit Nokia_3310_DC; Data or sbit Nokia_3310_DC at RB2_bit;
commande
extern sfr sbit Nokia_3310_CS; Chip select sbit Nokia_3310_CS at RB3_bit;
extern sfr sbit Nokia_3310_REST; Reset the lcd sbit Nokia_3310_REST at RB4_bit;
extern sfr sbit Nokia_3310_SCLK_dir; Clcok direction sbit Nokia_3310_SCLK_dir at TRISB0_bit;
pin.
extern sfr sbit Nokia_3310_SDA_dir; Data line sbit Nokia_3310_SDA_dir at TRISB1_bit;
direction pin.
extern sfr sbit Nokia_3310_DC_dir; D/C line sbit Nokia_3310_DC_dir at TRISB2_bit;
direction pin.
extern sfr sbit Nokia_3310_CS_dir; Chip select sbit Nokia_3310_CS_dir at TRISB3_bit;
direction pin.
extern sfr sbit Nokia_3310_REST_dir; Reset direction sbit Nokia_3310_REST_dir at TRISB4_bit;
pin.

Library Routines
 Nokia_3310_LCD_Init
 Nokia_3310_LCD_Clear
 Nokia_3310_LCD_Write_Text
 Nokia_3310_LCD_Write_CP
 Nokia_3310_Line_H
 Nokia_3310_Line_V
 Nokia_3310_Image
Author : Arezki YOUYOU e-mail : arezkiyouyou@gmail.com
Library : Nokia_3310_5110_Lcd Date : 27/07/2014
Microcontrollers : PIC12F, PIC16F, PIC18F, DSPIC, ARM(STM32)

Nokia_3310_LCD_Init for (PIC and DSPIC)


Prototype Void Nokia_3310_LCD_Init(void);

Returns  Nothing

Description Initializes Nokia Lcd module.

Requires  Nokia_3310_SCLK: Clock line pin


 Nokia_3310_SDA : Data line pin
 Nokia_3310_DC : Register Select (data/instruction) signal pin
 Nokia_3310_CS : Chip select pin
 Nokia_3310_REST: Reset pin
 Nokia_3310_SCLK_dir: Direction of the Clock line pin
 Nokia_3310_SDA_dir : Direction of the Data line pin
 Nokia_3310_DC_dir : Direction of the Register Select pin
 Nokia_3310_CS_dir : Direction of the Chip select pin
 Nokia_3310_RESTçdir: Direction of the Reset pin

must be defined before using this function.


Example // Lcd pinout settings
sbit Nokia_3310_SCLK at RB0_bit;
sbit Nokia_3310_SDA at RB1_bit;
sbit Nokia_3310_DC at RB2_bit;
sbit Nokia_3310_CS at RB3_bit;
sbit Nokia_3310_REST at RB4_bit;

// Pin direction
sbit Nokia_3310_SCLK_dir at TRISB0_bit;
sbit Nokia_3310_SDA_dir at TRISB1_bit;
sbit Nokia_3310_DC_dir at TRISB2_bit;
sbit Nokia_3310_CS_dir at TRISB3_bit;
sbit Nokia_3310_REST_dir at TRISB4_bit;
....
Nokia_3310_LCD_Init();
Author : Arezki YOUYOU e-mail : arezkiyouyou@gmail.com
Library : Nokia_3310_5110_Lcd Date : 27/07/2014
Microcontrollers : PIC12F, PIC16F, PIC18F, DSPIC, ARM(STM32)

Nokia_3310_LCD_Init for (ARM (STM32))


Prototype Void Nokia_3310_LCD_Init(void);

Returns  Nothing

Description Initializes Nokia Lcd module.

Requires  Nokia_3310_SCLK: Clock line pin


 Nokia_3310_SDA : Data line pin
 Nokia_3310_DC : Register Select (data/instruction) signal pin
 Nokia_3310_CS : Chip select pin
 Nokia_3310_REST: Reset pin

must be defined before using this function.


Example // Lcd pinout settings
sbit Nokia_3310_SCLK at GPIOD_ODR.B5;
sbit Nokia_3310_SDA at GPIOD_ODR.B1;
sbit Nokia_3310_DC at GPIOD_ODR.B2;
sbit Nokia_3310_CS at GPIOD_ODR.B3;
sbit Nokia_3310_REST at GPIOD_ODR.B4;

....

// Set GPIOC pins used for Nokia 3310 as digital output


GPIO_Digital_Output(&GPIOD_BASE, _GPIO_PINMASK_5 |
_GPIO_PINMASK_1|_GPIO_PINMASK_2|_GPIO_PINMASK_3|_GPIO_PINMASK_4);

Nokia_3310_LCD_Init();
Author : Arezki YOUYOU e-mail : arezkiyouyou@gmail.com
Library : Nokia_3310_5110_Lcd Date : 27/07/2014
Microcontrollers : PIC12F, PIC16F, PIC18F, DSPIC, ARM(STM32)

Nokia_3310_LCD_Clear
Prototype void Nokia_3310_LCD_Clear(void);

Returns  Nothing

Description clears the screen.

Requires Nokia_3310_LCD_Init must be called before using this routine

Example Nokia_3310_LCD_Clear();

Nokia_3310_LCD_Write_Text
Prototype void Nokia_3310 _Write_Text(char* message,char x_position,char y_position);

Returns  Nothing

Description Prints text on Nokia_3310 Lcd starting from specified position.

Parameters :
 message : message to be written
 x_position : starting position row number(from 0 to 84).
 y_position : starting position column number(from 0 to 6).
Requires Nokia_3310_LCD_Init must be called before using this routine.

Example Nokia_3310 _Write_Text(“willkommen”,5,1);


Author : Arezki YOUYOU e-mail : arezkiyouyou@gmail.com
Library : Nokia_3310_5110_Lcd Date : 27/07/2014
Microcontrollers : PIC12F, PIC16F, PIC18F, DSPIC, ARM(STM32)

Nokia_3310_LCD_Write_CP
Prototype void Nokia_3310 _Write_CP (void);

Returns  Nothing.

Description Prints text on Nokia_3310 Lcd at current cursor position.

Parameters :

message: message to be written


Requires Nokia_3310_LCD_Init must be called before using this routine
Example // Write text " ich bin Soltz! " at current x and y position:
Nokia_3310_Write_CP("ich bin Soltz! ");

Nokia_3310_Line_H
Prototype void Nokia_3310 _Line_H(char x_position_start, char y_position_start, char
x_position_stop);
Returns  Nothing.

Description Draws a horizontal line on Nokia 3310 lcd.

Parameters :

 x_position_start: x coordinate of the line start. Valid values: 0..83


 x_position_stop: x coordinate of the line end. Valid values: 0..83
 y_position_start: x coordinate of vertical line. Valid values: 0..6

Requires Nokia_3310_LCD_Init must be called before using this routine

Example Nokia_3310 _Line_H(10,3,40);


Author : Arezki YOUYOU e-mail : arezkiyouyou@gmail.com
Library : Nokia_3310_5110_Lcd Date : 27/07/2014
Microcontrollers : PIC12F, PIC16F, PIC18F, DSPIC, ARM(STM32)

Nokia_3310_Line_V
Prototype void Nokia_3310 _Line_V(char x_position_start, char y_position_start, char
y_position_stop);
Returns  Nothing.

Description Draws a virtical line on Nokia 3310 lcd.

Parameters :

 y_position_start: x coordinate of the line start. Valid values: 0..6


 y_position_stop: x coordinate of the line end. Valid values: 0..6
 x_position_start: x coordinate of vertical line. Valid values: 0..83

Requires Nokia_3310_LCD_Init must be called before using this routine

Example Nokia_3310 _Line_V(20,1,4);

Nokia_3310_Image
Prototype void Nokia_3310 _Image(char const image_for_nokia[504]);

Returns  Nothing.

Description Displays bitmap on Nokia 3310 Lcd.

Parameters :

 image_for_nokia: image to be displayed. Bitmap array must be


located in code memory.

 Use the mikroC PRO for PIC integrated Glcd Bitmap Editor to
convert image to a constant array suitable for displaying on Nokia
3310 LCD.

Requires Nokia_3310_LCD_Init must be called before using this routine

Example // Draw image Mein_kino on Nokia 3310 lcd


Nokia_3310 _Image (Mein_Kino);
Author : Arezki YOUYOU e-mail : arezkiyouyou@gmail.com
Library : Nokia_3310_5110_Lcd Date : 27/07/2014
Microcontrollers : PIC12F, PIC16F, PIC18F, DSPIC, ARM(STM32)

Library Example
The following code demonstrates usage of the Nokia 3310 or 5110 Lcd Library routines:

const char erste_Bild504]; // Use the mikroC PRO for PIC integrated Glcd Bitmap Editor 3310 to
//convert image to a constant array

// Nokia 3310 or 5110 LCD pinout settings

sbit Nokia_3310_SCLK at RB0_bit;


sbit Nokia_3310_SDA at RB1_bit;
sbit Nokia_3310_DC at RB2_bit;
sbit Nokia_3310_CS at RB3_bit;
sbit Nokia_3310_REST at RB4_bit;

// Pin direction
sbit Nokia_3310_SCLK_dir at TRISB0_bit;
sbit Nokia_3310_SDA_dir at TRISB1_bit;
sbit Nokia_3310_DC_dir at TRISB2_bit;
sbit Nokia_3310_CS_dir at TRISB3_bit;
sbit Nokia_3310_REST_dir at TRISB4_bit;

unsigned short i=0;


char * txt=”000”;
void short_to_String(unsigned short j){

txt[0]=j/100;
txt[1]=(j/10)%10;
txt[2]=j%10;
}

void main() {

Nokia_3310_LCD_Init();// initialize the Nokia 3310 or 5110 LCD


Nokia_3310_LCD_Clear();// Clear the Nokia 3310 or 5110 LCD
Nokia_3310 _Write_Text(“willkommen”,5,1); // write text
Delay_ms(2000);
Nokia_3310_LCD_Clear();// Clear the Nokia 3310 or 5110 LCD
Nokia_3310 _Image (erste_Bild);// Draw picture
Delay_ms(3000);
Nokia_3310_LCD_Clear();// Clear the Nokia 3310 or 5110 LCD
for(;;){
short_to_String(i); // convert short to string
Nokia_3310 _Write_Text(txt,40,3);//write text
i++;
Delay_ms(1500);
}

}
Author : Arezki YOUYOU e-mail : arezkiyouyou@gmail.com
Library : Nokia_3310_5110_Lcd Date : 27/07/2014
Microcontrollers : PIC12F, PIC16F, PIC18F, DSPIC, ARM(STM32)

RESET
VOUT
GND
CS
D/C
SDIN
SCLK
VCC

Nokia 3310 or 5110 Lcd connection

You might also like