Version 3

    This tutorial was extracted from Erich Styger blog http://mcuoneclipse.wordpress.com with his agreement.

     

    Freescale.bmp Kinetis-L.jpg

     

    The Freedom KL25Z board has a great price of less than $15. Adding a typical LCD usually will add a multiple of that price to the budget. But hey, there is a way to add a LCD to that board at almost no costs! With the idea that I have an old outdated Nokia phone, and the cost of a small capacitor plus some wires are considered as ‘zero’ ;-) .

     

    Say Hello from the Freedom Board

    Say Hello from the Freedom Board

     

     

     

    All what I need is:

    1. An old Nokia phone with one of these monocolor LCD displays
    2. Disassemble the phone to grab the display
    3. Adding a small capacitor and wires to my FRDM-KL25Z board
    4. Using a Processor Expert component as display driver
    5. Having fun :-)

     

    Nokia ‘Classic’ Phones

     

    A key reason for low price is high production volume. Similar to boards, this applies to other electronic goods as well, and this includes mobile phones. They are definitely produced in high volumes. Today is the area of smart phones, but not a long time ago Nokia was dominating the market with phones like the 3310:

     

    Nokia 3310 Mobile Phone

    Nokia 3310 Mobile Phone

     

     

     

     

    The Nokia 3310 and similar models are still available today in second-hand markets for a handful Euros. Or even available free of charge if you collect them from recycling stations. what is of interest for me are the displays: the phone features a 84×48 graphical LCD display.

     

     

     

     

    Another Way of Recycling

     

     

    I had one as well years ago, and was very happy with it. It still works. Since then, it was in a box with other ‘old’ electronics intended to use maybe later on. And I guess many of you have the same thing: such an old phone stored somewhere. So I decided give my old phone a new life (well, only for the display). And I have asked around in my family, and guess what: they were happy to give me their old phones. Asking students: and I had even more old phone displays to use :-) .

     

    I have found that I’m able to use the displays from following phone types:

     

    • Nokia 3210
    • Nokia 3310
    • Nokia 3330
    • Nokia 5510

     

    Disassembling the phone is rather easy. More problematic is to find out what kind of display/controller is used. Thanks to the SerDispLib project a lot of reverse engineering information is already available. 

      

     

     

     

    Type 1 or Type 2?

     

    There are two different types of displays known:

      

     

    Type 1 displays

       +-----------------------+

       |    1 2 3 4 5 6 7 8    |

       +-----------------------+

       |                       |

       |       Rear View       |

       |(Connector is visible) |

       |       LPH7779         |

       +-----------------------+

      

    Type 1 display has following pinout:

     

    • 1: Vdd (+5V or 3.3V, up to 7.4 mA)
    • 2: SCKL (SPI Clock)
    • 3: MOSI (SPI Master Out Slave In)
    • 4: D/C (Data or Command)
    • 5: SCE (SPI Chip Enable (Chip Select, active low))
    • 6: GND (Ground)
    • 7: VOUT (Display voltage out, connect with 1-4.7uF to ground, not connected to the microcontroller)
    • 8: RST (Reset, active low)

     

      

    Type 2 displays

       +-----------------------+

       |   1 2 3 4 5 6 7 8 9   |

       +-----------------------+

       |                       |

       |       Rear View       |

       |(Connector is visible) |

       |       LPH7366         |

       |                       |

       +-----------------------+

     

    Type 2 display has following pinout: 

     

    • 1: Vdd (+5V or 3.3V, up to 7.4 mA)
    • 2: SCKL (SPI Clock)
    • 3: MOSI (SPI Master Out Slave In)
    • 4: D/C (Data or Command)
    • 5: SCE (SPI Chip Enable (Chip Select, active low))
    • 6: External clock. Connect to Vdd.
    • 7: GND (Ground)
    • 8: VOUT (Display voltage out, connect with 1-4.7uF to ground, not connected to the microcontroller)
    • 9: RST (Reset, active low)

     

     

     

    Display Connector

     

      

    Basically the difference is the number of pins. I have found that some Nokia 3310 are especially useful as they have metal pins on the backside which makes it easy to solder wires on it, plus the needed capacitor:

     

    Nokia 3310 Display Rear Side with Pinout

    Nokia 3310 Display Rear Side with Pinout

     

     

    Other Nokia phones like the 5110 and 6150 are more problematic. The following picture shows the backside of the board:

     

    Backside of Nokia 5110 and 6150

    Backside of Nokia 5110 and 6150

     

     

    The issue is that not normal metal connectors are used. It uses kind of conductive ‘gum’ connector:

     

    Nokia 6150 LCD connector

    Nokia 6150 LCD connector

     

      

    :idea: Note the writing “LPH7366″ on the backside of the display which tells me the display controller used :-) .

     

    So instead of using metal contacts, it is using such conductive material to connect to the board. For this, the LCD display is pressed on the front side contacts of the board:

     

    Contacts on the front side of the board

    Contacts on the front side of the board

     

     

     

     

    The LCD itself has a metal frame which is clipped on the board. I decided to cut the board to have a connector plus the 6 green backlight LED on it:

     

     

    Board CutBoard Cut

      

      

    To connect to the my microcontroller board, I had to solder connection wires, and clipped the board to the PCB:

     

     

    Wired 5110 Display with LCD clipped on

    Wired 5110 Display with LCD clipped on

     

     

    Both the Nokia 5110 and 6150 have backlight LED’s on the board which I can use too :-) . The picture below shows the board wired to a breadboard and the green backlight LED’s of the display turned on:

     

    Breadboard Wiring with Backlight on

    Breadboard Wiring with Backlight on

     

     

     

     

    ‘Gum’ Connector

     

    But other (earlier?) Nokia 3310 are different again: their board has a lot of component on it:

     

     

    Nokia Phone Board with Connector

    Nokia Phone Board with Connector

     

     

     

     

    Here as well the ‘gum’ connector type is used:

     

    Nokia 3310 Display with 'Gum' Connector

    Nokia 3310 Display with ‘Gum’ Connector

     

     

     

     

    With these phones, the phone plastic cover is pressing the LCD on the base board. So for this kind of display another approach had to be used: a PCB with the connectors replicated and the capacitor on it:

     

     

    Connector PCB

    Connector PCB (Front Side)

     

     

     

     

    The back side of the board has a 2×5 connector on it for easier wiring:

      

     

    Connector PCB Back Side

    Connector PCB Back Side

     

     

     

     

    Then the display needs to be pressed on the PCB to make contact:

     

     

    Pressing Display on Connector PCB

    Pressing Display on Connector PCB

     

     

     

     

    A second revision of the connector board includes a plexiglass cover to press the display on the connector:

     

     

    LCD with Plexiglass Cover

    LCD with Plexiglass Cover

     

     

     

     

    Additionally, the second revision of the boards integrates LCD’s with backlight LED’s:

     

     

    Plexiglass cover with backlight LED display

    Plexiglass cover with backlight LED display

     

     

     

     

    Test Wiring to the Freedom Board

     

     

    I used a bread board to connect the Display to the Freedom board. To verify the signals, a logic analyzer is used.

      

     

    Connection to theFreedom  Board

    Connection to the Freedom Board

     

     

     

     

    PDC8544 Processor Expert Component

     

     

    According to the information in the internet, the display features a Philips PDC8544 controller. So the next thing was to develop a Processor Expert driver for it:

     

     

    PDC8544 Processor Expert Component

    PDC8544 Processor Expert Component

     

     

     

     

    The driver implements the low-level protocol and basic routines, including writing text to the display. Graphical routines like drawing lines/etc are subject of another component. But it is easy to write some text to the display with the low-level component.

     

    As there are different variants of the display, the type of the display plus supply voltage is configured in the component properties:

     

     

    PDC8544 Properties

    PDC8544 Properties

      

     

    Initialization Sequence and Communication Protocol

     

        

    The display uses 5 communication lines (beside of GND and Vcc):

     

     

    • D_C: Data or Command. Low for Command, High for Data
    • CLK: SPI clock signal
    • MOSI: SPI Master Out-Slave In
    • RES: Display Reset line
    • SCE: SPI chip select

    The display has no MISO line, as it is not possible to read from the display.

     

    The component Init() method initializes the display automatically:

    1. Setting RES and SCE to HIGH
    2. Waiting for 10 ms
    3. Setting RES to LOW
    4. Waiting 100 ms
    5. Setting RES to HIGH again

     

    The sequence is best shown with a logic analyzer:

     

     

    LCD Initialization Start Sequence 

    LCD Initialization Start Sequence

     

     

     

     

    Next, a sequence of command bytes is sent to the display:

     

     

    LCD Initialization Sequence

    LCD Initialization Sequence

     

     

     

     

    With 3V power supply, the sequence is 0×21 0xC8 0×13 0x 20 0×09, while for 5V display supply voltage it is 0×21 0xC2 0×13 0x 20 0×09.

     

    The screenshot below shows the SPI details of the first command:

     

     

    Sending 0x21 command

    Sending 0×21 command

     

     

     

     

    This means:

     

     

    • 8bit per transfer
    • MSB (Most Significant Byte) first
    • Clock Idle Polarity high (CPOL=1)
    • Data is valid on Clock Leading Edge (CPHA=0)

     

     

    Using it with the Freedom Board

     

    I used following connections on the FRDM-KL25Z Arduino header: 

     

     

    • D3: RES
    • D8: SCE
    • D9: D_C
    • D12: MOSI
    • D13: CLK

     

    FRDM-KL25Z Board Connections

    FRDM-KL25Z Board Connections

       

     

     

    This means following connections for the KL25Z microcontroller on the FRDM-KL25Z board:

      

    =================================================================

    SIGNAL LIST

    -----------------------------------------------------------------

    SIGNAL-NAME [DIR]        => PIN-NAME [PIN-NUMBER]

    -----------------------------------------------------------------

    CLK_D13 [Output]         => ADC0_SE5b/PTD1/SPI0_SCK/TPM0_CH1 [74]

    D_C_D9 [Output]          => ADC0_SE6b/PTD5/SPI1_SCK/UART2_TX/TPM0_CH5 [78]

    MOSI_D12 [Output]        => PTD3/SPI0_MISO/UART2_TX/TPM0_CH3/SPI0_MOSI [76]

    RES_D3 [Output]          => PTA12/TPM1_CH0 [32]

    SCE_D8 [Output]          => PTA13/TPM1_CH1 [33]

    =================================================================

     
     

    A Simple Demo Program

     

      

    Here is how to create a simple demo program to test the display:

     

    After having created a Processor Expert project in CodeWarrior for MCU10.3 (File > New > Bareboard Project), I add the PDC8544 component to my project. It will ask me to add a new Wait component. The PDC8544 will show an error as I need to further configure it:

      

     

    Added PDC8544

    Added PDC8544

     

     

     

     

    I need to add a new SPI component in the PDC1 properties:

     

     

    Add new SPIMaster_LDD Component

    Add new SPIMaster_LDD Component

     

     

     

     

    SPI Bus, RES and D/C Signals

     

      

    This will create a new SPIMaster_LDD component:

     

    Note: Processor Expert in MCU10.3 creates a new folder ‘Referenced_Components’

     

    The SPI component gets configured according to my pin mapping:

     

     

    SPI Configuration

    SPI Configuration

     

     

     

     

    If communication does not work well, try a slower clock rate. For me it worked well above 1 MHz.

    Next to configure the RES, SCE and D_C pins:

     

     

    RES Pin Configuration

    RES Pin Configuration

     

     

     

    SCE Pin Configuration

    SCE Pin Configuration

      

      

    D_C Pin Configuration

    D_C Pin Configuration

     

     

     

     

    Display Settings

     

     

    Finally, the display driver properties:

     

     

    The Type has to correspond to the display type used. The following types are supported:

     

     

    • LPH7366: Nokia 5110, 5120, 5130, 5160, 6110, 6150
    • LPH7677: Nokia 3210, 5510
    • LPH7779: Nokia 3310, 3315, 3330, 3350, 3410

     

      

    The Contrast is a bit tricky: depending on the display type, that value needs to be set differently. LPH7677 and LPH7779 typically need a value of 68, where LPH7366 needs a value around 50. In doubt, you need to experiment with that value. Additionally you can change the contract using the SetContrast() method at runtime. Last but not least it is needed to specify the correct supply voltage of the display, as the initialization is different for 3.3V and 5V displays: 

      

    PDC8544 Display Properties

    PDC8544 Display Properties

      

     

    Writing Text

     

      

    Now time to generate Processor Expert code and to add a few lines of code to write some text. WriteLineStr() writes a string to a line starting with number 1. To keep things simple I add my code into the main() routine in ProcessorExpert.c:

     

    01 int main(void)

    02 /*lint -restore Enable MISRA rule (6.3) checking. */

    03 {

    04 /* Write your local variable definition here */

    05 

    06 /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/

    07 PE_low_level_init();

    08 /*** End of Processor Expert internal initialization. ***/

    09 

    10 /* Write some text */

    11 PDC1_WriteLineStr(1, "Hello World");

    12 PDC1_WriteLineStr(2, "from the");

    13 PDC1_WriteLineStr(3, "KL25Z Freedom");

    14 PDC1_WriteLineStr(4, "Board!");

    15 /*** Don't write any code pass this line, or it will be deleted during code generation. ***/

    16 /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/

    17 #ifdef PEX_RTOS_START

    18 PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */

    19 #endif

    20 /*** End of RTOS startup code. ***/

    21 /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/

    22 for(;;){}

    23 /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/

    24 } /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/

      

    Compile, download and the result should be like this:

     

     

    Hello World

    Hello World

     

     

     

     

    Summary

     

      

    I’m able to get a free-of-charge used Nokia phones, or very cheap replacement parts from the internet. With this and the Processor Expert component created, it is very easy to integrate a small graphical LCD display to my FRDM-KL25Z board (or any other board). Which is a great thing and enhancements of my Freedom board for many projects. I hope you enjoy it as I do.

     

     

     

     

    Software

     

     

    A demo project is available from this link. The needed Processor Expert components are available from www.steinerberg.com/EmbeddedComponents: Wait and PDC8544.

     

     

     

     

    More? Yes!

     

      

    Well, it does not stop here. There are other Processor Expert components to draw lines, boxes, circles, images and fonts, as already shown in some of the pictures above. But this is a subject for a follow-up blog :-) .

     

     

     

    Further Information

    Happy Nokiaing :-)