Nokia lcd include , small footprint to suit pic16's


Results 1 to 40 of 111

Threaded View

  1. #17
    Join Date
    May 2013
    Location
    australia
    Posts
    2,645


    Did you find this post helpful? Yes | No

    Default Re: Nokia lcd include , small footprint to suit pic16's

    thanks mike , the concept works nicely

    xc8 version (393)+240 words , uses mssp1

    Code:
    #include "mcc_generated_files/mcc.h"
    #include "FONT.c"
    void putwreg(char work);
    void putcmd(char x);
    void WrChar(char ascii);
    void WrStr(char *);
    void main(void) {
        // initialize the device
        SYSTEM_Initialize();
        /*                                                                   *
         *  initialize Nokia 5110 LCD display                                *
         *                                                                   */
        __delay_ms(30); //
        LCD_RST_SetLow(); // 5110 'reset' pulse
        __delay_ms(1);
        LCD_RST_SetHigh(); // 5110 'reset' pulse
        __delay_ms(1);
        putcmd(0x20 + 0x01); // function set: extended instructions
        putcmd(0xc8);        // set Vop (contrast), 0..127
        putcmd(0x04 + 0x02); // set temperature coefficient, 0..3
        putcmd(0x10 + 0x03); // Set bias system, 0..7
        putcmd(0x20 + 0x00); // function set: standard instructions
        putcmd(0x08 + 0x04); // display control: normal mode
        putcmd(0x80 + 0x20); // set DDRAM X address, 0..83
        putcmd(0x40 + 0x02); // set DDRAM Y address, 0..5
        WrChar('R'); // write ascii character
        WrStr("eady");
        while (1) {
        }
    }
    /**
     End of File
     */
     
    void putwreg(char work) // send byte, msb first (15 words)
    {
        LCD_CE_LAT = 0; // spi enable on
        SPI1_Exchange8bit(work);
        while (!PIR1bits.SSP1IF);
        LCD_CE_LAT = 1; // spi enable off
    } //
    void WrChar(char ascii) // for packed 2.5 word 5x7 font
    {
        unsigned int dat, inx = 0x1f00;
        char i = 5;
        // char fd[6],i=5,*pt;
        //pt=fd;
        inx += ((ascii - 32)*5) >> 1;
        dat = FLASH_ReadWord(inx++);
        if (!(ascii & 1))putwreg(dat >> 7); //  *pt++=dat>>7;
        putwreg(dat & 0x7f);
        //*pt++ =(char)dat&0x7f;     
        dat = FLASH_ReadWord(inx++);
        putwreg(dat >> 7);
        putwreg(dat & 0x7f);
        //*pt++=dat>>7;   
        //*pt++=(char)dat&0x7f;   
        dat = FLASH_ReadWord(inx);
        //*pt++=dat>>7;
        putwreg(dat >> 7);
        if (ascii & 1) putwreg(dat & 0x7f); //*pt++=(char)dat&0x7f;
        //pt=fd;
        // while(i--){
        //    putwreg(*pt++); 
        // }
        putwreg(0);
    }
    void putcmd(char x) {
        LCD_DC_SetLow();
        putwreg(x);
        LCD_DC_SetHigh();
    }
    void WrStr(char *buff) {
        { //
            while (*buff) // while not end-of-string
                WrChar(*buff++); //
        }
    }

    font
    Code:
    #include <xc.h>
    #asm
    PSECT strings,class=CODE,abs,delta=2
    ORG 0x1f00 
    DW    0x0000, 0x0000, 0x0000, 0x005F, 0x0000    //  32 ' '  '!'
    DW    0x0007, 0x0007, 0x0014, 0x3F94, 0x3F94    //  34 '"'  '#'
    DW    0x122A, 0x3FAA, 0x0923, 0x0988, 0x3262    //  36 '$'  '%'
    DW    0x1B49, 0x2AA2, 0x2800, 0x0283, 0x0000    //  38 '&'  '''
    DW    0x001C, 0x1141, 0x0000, 0x20A2, 0x0E00    //  40 '('  ')'
    DW    0x0A08, 0x1F08, 0x0A08, 0x043E, 0x0408    //  42 '*'  '+'
    DW    0x0050, 0x1800, 0x0008, 0x0408, 0x0408    //  44 ','  '-'
    DW    0x0060, 0x3000, 0x0020, 0x0808, 0x0202    //  46 '.'  '/'
    DW    0x1F51, 0x24C5, 0x1F00, 0x217F, 0x2000    //  48 '0'  '1'
    DW    0x2161, 0x28C9, 0x2321, 0x20C5, 0x25B1    //  50 '2'  '3'
    DW    0x0C14, 0x097F, 0x0827, 0x22C5, 0x22B9    //  52 '4'  '5'
    DW    0x1E4A, 0x24C9, 0x1801, 0x3889, 0x0283    //  54 '6'  '7'
    DW    0x1B49, 0x24C9, 0x1B06, 0x24C9, 0x149E    //  56 '8'  '9'
    DW    0x0036, 0x1B00, 0x0000, 0x2B36, 0x0000    //  58 ':'  ';'
    DW    0x0414, 0x1141, 0x0014, 0x0A14, 0x0A14    //  60 '<'  '='
    DW    0x0041, 0x1114, 0x0402, 0x00D1, 0x0486    //  62 '>'  '?'  
    DW    0x1949, 0x3CC1, 0x1F7E, 0x0891, 0x08FE    //  64 '@'  'A'
    DW    0x3FC9, 0x24C9, 0x1B3E, 0x20C1, 0x20A2    //  66 'B'  'C'
    DW    0x3FC1, 0x20A2, 0x0E7F, 0x24C9, 0x24C1    //  68 'D'  'E'
    DW    0x3F89, 0x0489, 0x00BE, 0x20C9, 0x24FA    //  70 'F'  'G'
    DW    0x3F88, 0x0408, 0x3F80, 0x20FF, 0x2080    //  72 'H'  'I'
    DW    0x1040, 0x20BF, 0x00FF, 0x0414, 0x1141    //  74 'J'  'K'
    DW    0x3FC0, 0x2040, 0x207F, 0x010C, 0x017F    //  76 'L'  'M'
    DW    0x3F84, 0x0410, 0x3FBE, 0x20C1, 0x20BE    //  78 'N'  'O'
    DW    0x3F89, 0x0489, 0x033E, 0x20D1, 0x10DE    //  80 'P'  'Q'
    DW    0x3F89, 0x0CA9, 0x2346, 0x24C9, 0x24B1    //  82 'R'  'S'
    DW    0x0081, 0x3F81, 0x00BF, 0x2040, 0x203F    //  84 'T'  'U'
    DW    0x0FA0, 0x2020, 0x0FBF, 0x2038, 0x203F    //  86 'V'  'W'
    DW    0x3194, 0x0414, 0x3187, 0x0470, 0x0407    //  88 'X'  'Y'
    DW    0x30D1, 0x24C5, 0x2180, 0x3FC1, 0x2080    //  90 'Z'  '['
    DW    0x0104, 0x0410, 0x1000, 0x20C1, 0x3F80    //  92 '\'  ']'
    DW    0x0202, 0x0082, 0x0240, 0x2040, 0x2040    //  94 '^'  '_'
    DW    0x0001, 0x0104, 0x0020, 0x2A54, 0x2A78    //  96 '`'  'a'
    DW    0x3FC8, 0x2244, 0x1C38, 0x2244, 0x2220    //  98 'b'  'c'
    DW    0x1C44, 0x2248, 0x3FB8, 0x2A54, 0x2A18    // 100 'd'  'e'
    DW    0x047E, 0x0481, 0x010C, 0x2952, 0x293E    // 102 'f'  'g'
    DW    0x3F88, 0x0204, 0x3C00, 0x227D, 0x2000    // 104 'h'  'i'
    DW    0x1040, 0x223D, 0x007F, 0x0828, 0x2200    // 106 'j'  'k'
    DW    0x0041, 0x3FC0, 0x007C, 0x0218, 0x0278    // 108 'l'  'm'
    DW    0x3E08, 0x0204, 0x3C38, 0x2244, 0x2238    // 110 'n'  'o'
    DW    0x3E14, 0x0A14, 0x0408, 0x0A14, 0x0C7C    // 112 'p'  'q'
    DW    0x3E08, 0x0204, 0x0448, 0x2A54, 0x2A20    // 114 'r'  's'
    DW    0x023F, 0x2240, 0x103C, 0x2040, 0x107C    // 116 't'  'u'
    DW    0x0E20, 0x2020, 0x0E3C, 0x2030, 0x203C    // 118 'v'  'w'
    DW    0x2228, 0x0828, 0x220C, 0x2850, 0x283C    // 120 'x'  'y'
    DW    0x2264, 0x2A4C, 0x2200, 0x0436, 0x2080    // 122 'z'  '{'
    DW    0x0000, 0x3F80, 0x0000, 0x20B6, 0x0400    // 124 '|'  '}'
    DW    0x0808, 0x0410, 0x0478, 0x2341, 0x2378    // 126 '~'  ''
    #endasm
    Last edited by richard; - 25th May 2018 at 10:42.
    Warning I'm not a teacher

Similar Threads

  1. Using Nokia LCD
    By BobP in forum mel PIC BASIC Pro
    Replies: 300
    Last Post: - 3rd May 2018, 04:47
  2. 16F946 pcb footprint (64 tqfp)
    By nomad in forum Schematics
    Replies: 2
    Last Post: - 8th September 2009, 11:14
  3. small 2X16 LCD
    By Ron Marcus in forum Off Topic
    Replies: 2
    Last Post: - 26th October 2007, 20:37
  4. Nokia 3310 LCD
    By barkerben in forum General
    Replies: 3
    Last Post: - 10th December 2005, 19:08
  5. Small LCD module,character
    By Ron Marcus in forum Off Topic
    Replies: 6
    Last Post: - 27th November 2005, 18:13

Members who have read this thread : 3

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts