My "Library" for ST7920 Graphical displays, works fine, but...


Closed Thread
Results 1 to 32 of 32

Hybrid View

  1. #1
    Join Date
    Feb 2013
    Posts
    1,078

    Default My "Library" for ST7920 Graphical displays, works fine, but...

    Hello.
    There are LCD modules, based on ST7920 controller, which are pin and command compatible with HD44780 controllers, so they can be used with PBP, by using LCDOUT statement. This saves a lot of time, can be run on almost any PIC, no need for includes and so on. Also, with these, any existing project can be easily updated, since no need to change PCB or hardware layouts. At the current stage, I'm using a 1602 compatible module, which has same physical outline, but has resolution of 144x32 pixels, instead of 80x16 of standard 1602. This allows to have 4 lines of 18 character text on screen, instead of 2 lines x 16 character, with better looking 7x7 font. If 5x7 font will be used, it will be possible to display 24 characters per line. The attached picture shows my ASCII 7x7 font for that display. The code is here.

    Code:
    LCDOUT $FE,$2E  'enable graphic mode
    pause 1
    gosub gpt 'clear screen after switching to graphics mode
    topline	var byte [18]
    arraywrite topline, ["0123456789:;<=>?@ "]
    C=0 'line number multiplied by 8
    gosub GCODER
    arraywrite topline, ["ABCDEFGHIJKLMNOPQR"]
    c=8
    gosub gcoder
    arraywrite topline, ["STUVXYZ[\]&_`abcde"]
    c=16
    gosub gcoder
    C=24
    arraywrite topline, ["fghijklmnopqrstuvw"]
    GOSUB GCODER
    stop
    GCODER:
    FOR X=0 TO 17 step 2	'READ ARRAY INTO VARIABLE, ARRAY MEMBER CHAR=EEPROM OFFSET	
    Y=(topline[x])*8-264
    Z=(topline[x+1])*8-264 'READ  INTO VARIABLE AS TWINS
    FOR I=0 TO 7	'HELPER LOOP FOR CHARACTER READING
    i2cread sda, scl, adr, y+i, [a]
    i2cread sda, scl, adr, z+i, [b]
    LCDOUT $FE,$80+i+c 'UPDATE Y POSITION
    LCDOUT $FE,$80+x/2 'UPDATE X POSITION
    if topline[x]=32 then a=0
    if topline[x+1]=32 then b=0 'blanker to display space (32)
    LCDOUT a
    LCDOUT b 'WRITE TO SCREEN
    NEXT I
    NEXT X
    return
    GPT:   'clear screen
    z=0
    for y=0 to 32
    LCDOUT $FE,$80+y
    LCDOUT $FE,$80
    FOR x=1 TO 18
    LCDOUT z
    NEXT
    next
    return
    At initial state, I was using on chip eeprom for storing font data, and using READ statement to read it. The speed was very fast - fast enough that I can do smooth scrolling, and some old school jumping lines/letters, parallax scrolling effects. But since in most PICs, on-chip eeprom is limited to 128 or 256 bytes, that amount is not enough to store complete ASCII character set. So I decided to use an external, I2C eeprom for font data storage. In this particular case, I'm using 24C256 chip. It works fine, but there's an issue with speed. Now, to re-read characters needed for complete screen display (576 bytes), it needs approximately 1 second, which makes smooth scrolling and other, "realtime" effects impossible.

    So the question is following: This slowdown is definitely happens over I2C, because with on chip eeprom, everything is very fast. Is this caused by PBP limitation of I2C implementation, or the 24C256 is slow by it's nature and can't be read that fast? So what are ways of solving this? Use hardware I2C? (how?) use faster eeprom chip (which?)

    Thanks!

    Name:  geofont.jpg
Views: 1088
Size:  236.9 KB

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,516


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: My "Library" for ST7920 Graphical displays, works fine, but...

    Store the font data in program memory instead.

  3. #3
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: My "Library" for ST7920 Graphical displays, works fine, but...

    I'm using 24C256 for a good reason - due to amount of data being used
    Also, when using program memory, it won't be that easy to form the letters, as I do in the example above.

  4. #4
    Join Date
    Aug 2011
    Posts
    408


    Did you find this post helpful? Yes | No

    Default Re: My "Library" for ST7920 Graphical displays, works fine, but...

    But since in most PICs, on-chip eeprom is limited to 128 or 256 bytes
    Would 1K of EEPROM be enough for what you're doing?

    If so, switch to a pic18, like an 18F26K22. It'll be MUCH faster than trying to read from an I2C EEPROM.

  5. #5
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: My "Library" for ST7920 Graphical displays, works fine, but...

    24C256 is 32KB EEPROM.
    So I'm using it, because I need that much amount of font/graphics data

  6. #6
    Join Date
    Aug 2011
    Posts
    408


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: My "Library" for ST7920 Graphical displays, works fine, but...

    In that case, if you're looking for speed then an I2C EEPROM isn't the best of choices.

    I have no idea how slow the bit-banged I2CREAD is (probably pretty slow).
    A 24C256 isn't all that slow, but you're going to be limited to about 400KHz using the pic's MSSP hardware.
    That means a random read operation works out to something like 120us/byte @ 400KHz.

    A faster choice would be an SPI EEPROM like a 25LC512. There you'll probably be able to get the MSSP to run at 8MHz,
    which would speed up the random read to about 5-10us/byte.

    If you can read more than 1 byte at a time then the operations are a bit faster, but Henrik's suggestion of using program memory would be faster.

Similar Threads

  1. Graphical Displays with PBP3
    By richard in forum PBP3
    Replies: 95
    Last Post: - 25th February 2024, 15:09
  2. How to do the "SerIN" and "SerOut " for the usb ?
    By vicce67 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 13th March 2015, 03:01
  3. Replies: 0
    Last Post: - 14th November 2013, 04:32
  4. Replies: 3
    Last Post: - 15th October 2012, 09:06
  5. Replies: 1
    Last Post: - 16th February 2005, 21:05

Members who have read this thread : 2

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