Author Topic: NHD-0420CW-AB3 init / cgram  (Read 3665 times)

blowtorch

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
    • View Profile
NHD-0420CW-AB3 init / cgram
« on: July 28, 2015, 03:45:40 PM »
Hi, while trying to get cgram working I realise the display is always on ROMC. Whilst checking example init routine, I am also unsure of the 2 calls to the "data" function, as opposed to the "command" function.  My understanding of the data sheet would be to enter extended command mode, then send 0x71 for function selection A, then 0x00 to disable vregulator.  But all the example code would send the 0x71, then 0x40, then 0x00.

Ditto the initialisation code that does the ROM selection and cgram:  Example given:
    command(0x72); // function selection B
    data(0x00);  // by using the "data" function call, it actually sends 0x40 then 0x00

Seems like either I don't understand it or its a bug?   :)

On to the main problem:  I cannot get ROM A and cgram enabled.  Have tried sending 0x72 0x40 0x00  or 0x72 0x00 etc.

Any ideas?

blowtorch

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
    • View Profile
Re: NHD-0420CW-AB3 init / cgram
« Reply #1 on: August 03, 2015, 12:40:09 AM »
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.   

Saurabh_B

  • Administrator
  • Hero Member
  • *****
  • Posts: 355
  • Karma: 10
    • View Profile
Re: NHD-0420CW-AB3 init / cgram
« Reply #2 on: August 03, 2015, 10:18:40 AM »
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:
Code: [Select]
command(0x40);
  data(0x1F);
  data(0x15);
  data(0x15);
  data(0x04);
  data(0x04);
  data(0x15);
  data(0x15); 
  data(0x1F);


blowtorch

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
    • View Profile
Re: NHD-0420CW-AB3 init / cgram
« Reply #3 on: August 04, 2015, 06:07:09 AM »
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?

Saurabh_B

  • Administrator
  • Hero Member
  • *****
  • Posts: 355
  • Karma: 10
    • View Profile
Re: NHD-0420CW-AB3 init / cgram
« Reply #4 on: August 04, 2015, 08:17:07 AM »
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..


blowtorch

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
    • View Profile
Re: NHD-0420CW-AB3 init / cgram
« Reply #5 on: August 05, 2015, 06:55:28 AM »
Sure - its pretty standard stuff as per datasheet:

Init procedure:
Code: [Select]
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.

Saurabh_B

  • Administrator
  • Hero Member
  • *****
  • Posts: 355
  • Karma: 10
    • View Profile
Re: NHD-0420CW-AB3 init / cgram
« Reply #6 on: August 05, 2015, 08:15:44 AM »
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.

blowtorch

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
    • View Profile
Re: NHD-0420CW-AB3 init / cgram
« Reply #7 on: August 06, 2015, 04:26:10 AM »
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.

Saurabh_B

  • Administrator
  • Hero Member
  • *****
  • Posts: 355
  • Karma: 10
    • View Profile
Re: NHD-0420CW-AB3 init / cgram
« Reply #8 on: August 06, 2015, 07:52:17 AM »
Glad to see  everything worked out.

 

NHD‐0420CW‐AB3 I2C Interface

Started by andersonpdBoard OLEDs

Replies: 1
Views: 2628
Last post January 23, 2015, 10:00:06 AM
by Michael_L
NHD‐0420CW‐AG3 Contrast question

Started by RichardRBoard OLEDs

Replies: 2
Views: 2138
Last post January 16, 2016, 09:52:02 AM
by RichardR
NHD‐0420CW‐AG3: blinking part of text?

Started by RichardRBoard OLEDs

Replies: 2
Views: 2294
Last post February 28, 2017, 03:27:02 PM
by BobG
NHD‐0420CW‐AG3 + I2C + PIC assembly code: trouble getting started

Started by RichardRBoard OLEDs

Replies: 4
Views: 3126
Last post December 17, 2015, 03:12:49 AM
by RichardR
MOVED: NHD-0420CW-AY3 display, text is mirror image

Started by Saurabh_BBoard Character LCDs

Replies: 0
Views: 2061
Last post March 11, 2016, 07:51:03 AM
by Saurabh_B