NHD-0420CW-AB3 init / cgram

Comments

8 comments

  • blowtorch

    Anyone? 

    I really need CGRAM to be working on this display.

    Maybe I was not clear in first post above.  My main concern is that I cannot select the correct ROM and CGRAM which I need to be able to do.

    The other secondary concern is more my understanding of the way the sample source code supplied works.   

    0
  • Saurabh_B

    That 0x72 followed by data 0x00, selects ROM A.

    I was wondering if you could post the code of how you are accessing the CGROM to put a character in the memory; also how you are printing the character out.

    Example for what I have done to load a custom character in is:

    command(0x40);
      data(0x1F);
      data(0x15);
      data(0x15);
      data(0x04);
      data(0x04);
      data(0x15);
      data(0x15); 
      data(0x1F);
    0
  • blowtorch

    Yes I have read the data sheet re 0x72 then 0x00. But my point re the code, is that by using the sample functions, the function named "data" actually sends ox40 then 0x00.  It works, because only the 4 LS bits need to be set to 0. But how would you then select ROM B?

    Anyway that is not my problem, I am driving the OLED from a PIC with my own routines I have coded.

    My problem, is that selecting ROM A does not work.  All the other routines work, but sending 0x72 followed by 0x00 is ignored. This I check by outputting the 1st 20 characters in CGROM, the characters displayed are from ROM C.

    I suspect hardware fault on the boards, the datasheet for the controller says that one needs resistors to enable ROM selection.  Does Newhaven monitor this forum or should I make official contact with them?

    0
  • Saurabh_B

    I was wondering if it would be possible to see your code specifically how you are writing either data or commands to the display. Also where you are selecting the ROM for custom characters..

    0
  • blowtorch

    Sure - its pretty standard stuff as per datasheet:

    Init procedure:

    uint8 LCD_US2066_Init() { // ok
    uint8 ack;
    I2C_Start();
    ack=I2C_Write(LCD_US2066_ADDR);
    if (ack!=0) return(ack);
    ack=I2C_Write(0x2A); //function set (extended command set)
    ack=I2C_Write(0x71); //function selection A
    ack=I2C_Write(0x00);  // **** disable internal VDD regulator
    ack=I2C_Write(0x28); //function set (fundamental command set)
    ack=I2C_Write(0x08); //display off, cursor off, blink off
    ack=I2C_Write(0x2A); //function set (extended command set)
    ack=I2C_Write(0x79); //OLED command set enabled
    ack=I2C_Write(0xD5); //set display clock divide ratio/osc freq
    ack=I2C_Write(0x70); //set display clock divide ratio/osc freq
    ack=I2C_Write(0x78); //OLED command set disabled
    ack=I2C_Write(0x09); //extended function set (4-lines)
    ack=I2C_Write(0x06); //COM SEG direction
    ack=I2C_Write(0x72); //function selection B. Choose ROM set & CGRAM
    ack=I2C_Write(0x00); //Select CGRAM & character ROM 0
    ack=I2C_Write(0x2A); //function set (extended command set)
    ack=I2C_Write(0x79); //OLED command set enabled
    ack=I2C_Write(0xDA); //set SEG pins hardware configuration
    ack=I2C_Write(0x10); //set SEG pins hardware configuration
    ack=I2C_Write(0xDC); //function selection C
    ack=I2C_Write(0x00); //function selection C
    ack=I2C_Write(0x81); //set contrast control
    ack=I2C_Write(0x02); //set contrast control 0x7F default
    ack=I2C_Write(0xD9); //set phase length
    ack=I2C_Write(0xF1); //set phase length
    ack=I2C_Write(0xDB); //set VCOMH deselect level
    ack=I2C_Write(0x40); //set VCOMH deselect level
    ack=I2C_Write(0x78); //OLED command set disabled
    ack=I2C_Write(0x28); //function set (fundamental command set)
    ack=I2C_Write(0x01); //clear display
    ack=I2C_Write(0x80); //set DDRAM address to 0x00
    ack=I2C_Write(0x0C); //display ON
    I2C_Stop();
    delay_ms(100);  //delay
    return 0;

    }

    As mentioned, standard other than adjusting contrast. I also have the other normal functions that allow one to set contrast, position clear screen etc. All works ok.
     
    A small test program displaying the first 80 characters clearly shows ROMC is still selected, despite the sequence in the init routine to select ROMA.

    0
  • Saurabh_B

    One thing I've noticed and I'm not sure if you're doing it else where, the (0x00) you are sending for ROM selection should be sent as data and not a command. Same would be true when you are disabling the internal voltage regulator.

    0
  • blowtorch

    Hi Sauraub

    OK fixed, thank you.  If you look at the op you can see I was asking about that.  When reading the datasheet I missed the data bit that needs to be set for "data" mode, but picked it up in the example init routine.  I did not realise that one must first send the command byte, then command value, then data byte and finally data value.

    Funny enough I did try that as well previously, with no success, but probably need a POR between that I missed or something. 

    Thanks again.

    0
  • Saurabh_B

    Glad to see everything worked out.

    0

Please sign in to leave a comment.