Nokia lcd include , small footprint to suit pic16's


Results 1 to 40 of 111

Threaded View

  1. #6
    Join Date
    Aug 2005
    Location
    Michigan, USA
    Posts
    224


    Did you find this post helpful? Yes | No

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

    Yes, I already thought about using the SPI module. The current bit-bang driver uses 14 words of memory and runs at ~190-kb/s (with 8-MHz clock). An SPI driver and its init code shouldn't be any bigger. I hope to work on an SPI driver later today. I just need to refresh my memory on the SPI modes. Looks like you're using CKE = 1 and CKP = 0, yes?

    Name:  spi modes.png
Views: 11861
Size:  156.5 KB

    Implementing the 'packed' font table and extracting data was surprisingly simple, though I'm coding pretty close to the metal and the results are nothing as agile or elegant as your use of the 'readcode' function. Here's an excerpt, if you're interested;

    Code:
      /********************************************************************
       *                                                                  *
       ********************************************************************/
       void RdFlash()               // bank 3 (inserted by compiler)
       { asm bcf     _eecon1,CFGS   // not 'config' memory            |03
         asm bsf     _eecon1,EEPGD  // select 'program' memory        |03
         asm bsf     _eecon1,RD     // initiate read operation        |03
         asm nop                    // required nop                   |03
         asm nop                    //  "                             |03
         asm incf    _eeadrl,F      // bump EEADR                     |03
         asm btfsc   _status,Z      //  "                             |03
         asm incf    _eeadrh,F      //  "                             |03
         asm rlf     _eedatl,W      // move b7 into Carry             |03
         asm rlf     _eedath,W      // wreg = the 7 bit hi byte       |03
         asm bcf     _eedatl,7      // eedatl = the 7 bit lo byte     |03
       }                            //
    
      /********************************************************************
       *                                                                  *
       ********************************************************************/
       void WrChar(char ascii)      // WrChar() for packed 5x7 font
       { asm movf    _ascii,W       // ascii char value, 32..127      |00
         asm addlw   -32            // minus table offset             |00
         asm movwf   _ascii         // font array index, 0..95        |00
     /*                                                                   *
      *  multiply index by 3 (0..95 -> 0..285), add table base address,   *
      *  and stuff the result in the EEADR register pair.                 *
      *                                                                   */
         asm lslf    _wreg,W        // wreg = (ascii-32)*2            |00
         asm addwf   _ascii,W       // wreg = (ascii-32)*3            |00
      // asm movlb   3              // bank 3 (inserted by compiler)  |03
         asm movwf   _eeadrl        // flash address lo               |03
         asm movlw   1024/256       // table address hi               |03
         asm btfsc   _status,C      // overflow? no, skip, else       |03
         asm addlw   1              // bump value                     |03
         asm movwf   _eeadrh        // flash address hi               |03
     /*                                                                   *
      *  read 3 words (6 bytes) of font pattern data from the 5x7 font    *
      *  array and write them to the Nokia 5110 LCD.                      *
      *                                                                   */
         for(char i=0; i<3; i++)    // 
         { RdFlash();               // read one word (2 bytes)
           putlcd(wreg);            // send hi byte
           putlcd(eedatl);          // send lo byte
         }                          //
       }                            //
    
      /********************************************************************
       *                                                                  *
       ********************************************************************/
       void WrChar(rom char *data)  // overload function for strings
       { char ndx = 0;              //
         while(data[ndx++])         // while not end-of-string
           WrChar(wreg);            //
       }                            //
    Code:
     /*                                                                   *
      *  initialize Nokia 5110 LCD display                                *
      *                                                                   */
         delay_ms(30);              //
         rst = 0;                   // 5110 'reset' pulse
         rst = 1;                   //
         dc = 0;                    // command mode
         putlcd(0x20+0x01);         // function set: extended instructions
         putlcd(0x80+0x30);         // set Vop (contrast), 0..127
         putlcd(0x04+0x02);         // set temperature coefficient, 0..3
         putlcd(0x10+0x03);         // Set bias system, 0..7
         putlcd(0x20+0x00);         // function set: standard instructions
         putlcd(0x08+0x04);         // display control: normal mode
    
         putlcd(0x80+0x20);         // set DDRAM X address, 0..83
         putlcd(0x40+0x02);         // set DDRAM Y address, 0..5
         dc = 1;                    // data mode
         WrChar("Hello");           // test string overload function
    Thank you again for sharing your work. Mike
    Last edited by Mike, K8LH; - 18th May 2018 at 15:49. Reason: additional code excerpt

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 : 0

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