Menu

ST7032 custom characters

Help
2017-04-27
2017-04-27
  • David Stephenson

    I can get a LCD using I2C to work with the built in characters, but I want to create some custom characters (to give a battery condition bar graph) and I am having difficulty. Has anybody got any experience of doing this?
    Here is my code that does not work...

    SUB CUSTOM
    
    HI2CSTART
    HI2CSEND(Sl)
    HI2CSEND(Comsend) '0x00
    HI2CSEND(0x40) 'Set CGRAM address to 0x00
    HI2CSTOP
    WAIT 10 ms
    
    hI2CStart
    HI2CSEND(Sl)
    HI2CSEND(DS)
    HI2CSEND(0x1F)  'write to first CGRAM address
    HI2CSEND(0x1F)
    HI2CSEND(0x1F)
    HI2CSEND(0x1F)  
    HI2CSEND(0x1F)
    HI2CSEND(0x1F)
    HI2CSEND(0x00)
    HI2CSEND(0x00)
    HI2CStop
    end sub
    
     
  • Anobium

    Anobium - 2017-04-27

    Can you attach the rest of the code to give us the context? Someone can then none have to sort the preamble.

     
  • David Stephenson

    So it's a LCD made by Midas and it has a ST7032 controller. The standard (ASCII) charcters display, but when I try for custom characters it does not appear to work.

     
  • Anobium

    Anobium - 2017-04-28

    Looking at the code.. my first question is why are you not using the standard I2C driver for LCD and then all should work?

       #define LCD_IO 10
       #define LCD_I2C_Address_1 0x7C
    
       'You may need to use SLOW or MEDIUM if your LCD is a slower device.
       #define LCD_SPEED FAST
       'You may need to invert these states. Dependent of LCD I2C adapter.
       #define LCD_Backlight_On_State  1
       #define LCD_Backlight_Off_State 0
    

    Did you try this? As I would expect all to work out of the box.

     
  • David Stephenson

    I wrote the code when the GCBasic compiler only supported HD44780 character displays (I always use the standard driver for these and I can make custom characters).
    I thought this particular LCD controller (ST7032) was not supported.
    Some of the setting for the display OSC, contrast and follower need to be set for this display to work, and it seems to be easier to write custom code to do this.
    It is not that difficult to write the code. Clearly I'm missing something or have done something daft that is causing the custom character to not load.
    I also have several other I2C devices connected to the same two wires so I prefer to have as much control over what is happening as possible.

     
  • Anobium

    Anobium - 2017-04-28

    OK. I would open up the LCD library and take the code from there. But, this is all based on a standard approach but should work.

     
  • David Stephenson

    I've looked at the code in the mylcd.h file and except for delays between writes it is the same code as I am using. So I tried with the delays (50 us) and still nothing.
    I'm going to give up for the moment.

     
  • stan cartwright

    stan cartwright - 2017-04-29

    the data sheet says l Character Generator RAM (CGRAM)
    In the character generator RAM, the user can rewrite character patterns by program. For 5 x 8 dots, eight
    character patterns can be written.
    Write into DDRAM the character codes at the addresses shown as the left column of code table (refer to
    appendix) to show the character patterns stored in CGRAM.
    See Table 4 for the relationship between CGRAM addresses and data and display patterns. Areas that are not
    used for display can be used as general data RAM.
    l ICON RAM
    In the ICON RAM, the user can rewrite icon pattern b
    All sounds complicated.

     
  • David Stephenson

    Yes Stan much of the data sheet looks like it was generated from a google translation.

     
  • David Stephenson

    I have solved the problem. Before calling the routine to load custom character(s) there needs to be a short delay (I have used 1ms - probably excessive).
    So here's the routine to load a bar-graph into character(0) the size of the graph depends on the variable BAT.
    It is also used to adjust the contrast of the LCD display as the battery goes down.
    The voltage is detected using the ADC relative to the internal (selectable)reference of 2.048V.

    chht=0x34
    SL=0x7C
    DS=0x40
    SUB CUSTOM
    hi2cstart
    hi2csend(SL)
    HI2CSEND(0x00) 'cmd send
    hi2csend(chht) 'iset=0
    HI2CSEND(0x40) 'Set CGRAM address to 0x00
    HI2CSTOP
    hi2cstart
    HI2CSEND(SL)
    hi2csend(DS) 'data send
    for i = 0 to 7
    nl=0x1F
    if BAT>i then nl=0x00
    HI2CSEND(nl)    'write to CGRAM addresses
    next i
    HI2CStop
    HI2CSTART
    HI2CSEND(Sl)
    HI2CSEND(Comsend) '0x00
    hi2csend(chht+1) 'iset back to 1
    hi2cstop
    end sub
    
     
  • William Roth

    William Roth - 2017-05-13

    Hi David,

    It's great that you have resolved this problem. However, adding a delay may just be a workaround and may not be addressing the root cause of the problem. So help us out a bit here.

    What command or code was executed immmediately prior to calling the sub? .Seeing the added delay in context may help to diagnose the root cause.

    Can you post more complete code so that we can see what preceeds the call to the sub and exactly where you have added the delay?

    William

     
  • David Stephenson

    It was immediately after the initialization of the LCD (setting OSC, Power, follower etc). Probably everything has to settle before the LCD will accept any data.
    I've now put the routine elsewhere as I really only need to create a new character when a detectable change in battery voltage has happened. So basically it was like this...

    Intialize LCD
    wait 1 ms
    load custom character

    without the 1 ms the character did not load.

    Completely different question Can I switch on spell-checking when I'm posting here?

     
  • William Roth

    William Roth - 2017-05-15

    That makes sense. According to the Sitronix ST7032 datasheet (page 19) the instruction execution time of "Clear Display" is between .58 and 1.08 ms. So any time a "Clear Display" is issued it should be followed by a 1 or 2 ms delay, depending upon OSC speed. The same applies to "Clear Home".

     

    Last edit: William Roth 2017-05-15

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.