Author
Topic: NHD-C12864B2Z-RN-FBW Arduino Uno (Read 8907 times)

Hello again...After this board has had all its content dropped, I thought I should post again to see if you can help me further.As you know I am struggling to get this screen to work. I am now using an I2C I/O expander and two 4050 chips to do the logic conversion to 3.3V I have debugged the outputs using LEDs and I am confident that the code which I attach is sending the correct stuff to the interface (through a NHD-FFC28). I have checked and double checked everything and still I get nothing from the screen. When I test without the screen connected it all looks correct, when the screen is inserted into the FFC28 the LEDs dont flash the same way at all...I am using capacitors from Farnell part number (8126933).

//***************************************************//The setup() function is called//when a sketch starts. Use it to//initialize variables, pin modes,//start using libraries, etc. The//setup function will only run once,//after each powerup or reset of the Arduino board.//***************************************************void setup(){ Serial.begin(9600);

I noticed you are using an i2c interface, and I just want to make sure you know this display only has a parallel interface. I see you mentioned you are using an i2c I/O expander, so I will assume this is converting your i2c data into 8 separate bits and putting the byte on the display's data bus. If this is the case, then when I looked at your code I noticed you are using 6800 mode protocol for the parallel interface, when this display is actually only 8080 mode. You will need to modify your write command/data functions to correct this. I actually have some Arduino code for our NHD-C12864KGZ display, which uses the same controller. The code will work for the display you are using too, but more importantly, you can use it as reference to correctly write commands and data in your software.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.*///---------------------------------------------------------

// The 8 bit data bus is connected to PORTA of the Arduino Mega2560// 5V voltage regulator on Arduino Mega has been replaced with a 3.3V regulator to provide 3.3V logic

//***************************************************//The setup() function is called//when a sketch starts. Use it to//initialize variables, pin modes,//start using libraries, etc. The//setup function will only run once,//after each powerup or reset of the Arduino board.//***************************************************void setup(){ Serial.begin(9600);

//***************************************************//the loop() function does precisely what its name suggests, //and loops consecutively, allowing your program to change //and respond. Use it to actively control the Arduino board.//***************************************************void loop(){ disp(); delay(10000);}But still no joy.Brings me back to my original question about checking the power supply is operating correctly???

The code that I sent you is working code, I tested it this morning to be 100% certain. Therefore, the problem should not lie within your software. As for your power supply concern, what exactly do you mean? I assume you are powering the display with 3.3V, and all 9 capacitors are in the appropriate places and soldered properly (this can be seen on page 4 of the datasheet). Are you making sure to align the display's FFC cable to whatever side of the NHD-FFC28 you are using as pin 1? The display is 27-pin, and the breakout board is 28, so you need to be very careful ensuring it is aligned in the connector properly.

If all of the above is verified to be correct, and your connections are all correct, then the only other thing to troubleshoot would be your I/O expander and level shifters. Since you are using the Arduino, could you try using the Arduino's parallel port instead? It would be PORTD[7..0], (digital pins [7..0]). I am trying to eliminate any possible causes of error from your setup, since the code is verified to be correct.

Hey Michael, just before anything else... I appreciate the help and I am very pleased with your responses so far. I am however a bit disappointed with the misleading information in the Datasheet document (particularly the example code applying to a scheme that the device doesnt support 8080 vs 6800 i just followed the example thinking it was right and the commented out little bits didn't make that any easier either)...

To answer your question, I have rechecked all the wiring and I have been very aware of the 27 vs 28 pin issue and also if you remember emailed you on the orientation of the connector which I understand is "pins" down towards the board... (btw yes have offset the ribbon to pin 2 - 28, and checked all connections again).

I had written a long number of questions.... but as I have now got the code and screen working!!!!! I don't need them answered.

The problems were two fold..

1) I hadn't level shifted the control lines... only the DB0-7 lines.... DOH2) I was debugging the "on off" states of the pins by putting LEDs on the driven side of the level shifter... this dragged the voltages down to an unacceptable level for them to be considered "HIGH" etc...

Thanks so much for all the help... are there any "low level" functions that I can grab to drive the screen to do simple tasks like fill an area (rectangle) etc... and write text on it?THANKS again.

// this code expects an IO expander (MCP23017) on the I2C bus at address 0x20// two level shifters (74HC4050) are used to migrate the levels from 5v to 3.3v// pins for the control lines are self explanitory

//***************************************************//The setup() function is called//when a sketch starts. Use it to//initialize variables, pin modes,//start using libraries, etc. The//setup function will only run once,//after each powerup or reset of the Arduino board.//***************************************************void setup(){ Serial.begin(9600);

//***************************************************//the loop() function does precisely what its name suggests, //and loops consecutively, allowing your program to change //and respond. Use it to actively control the Arduino board.//***************************************************void loop(){ disp(); delay(1000);}

Actually I now do have some questions, because the ST7565R documentation is so difficult to follow...

how do i achieve a "Read Data" and a "Read Status" from a point of view of the control lines...

I am not sure how the code you have given relates to the table of commands, because the documents don't show the transitions required on the control pins to achieve them. ( and I am not entirely convinced by the timing diagram because it seems like a general setup?) Is it just a case of having the WR PIN in the opposite state? In which case for (7) Display data read I will need A0 to be HIGH, RD LOW, and WR HIGH... we never toggled RD before... should the WriteData and WriteCommand functions now make sure of the state of RD?

Of course... with my unidirectional level shifters... I wont be able to read the status of the pins... But I would like to know the correct approach for doing readData and readStatus

for (count=0;count<5;count++)//each character is 8 px tall { data_out(Ascii_1[letter][count]); }}The "letter" parameter would be the number of what letter you want from the font table (the number in the parentheses). For example, if you wanted to put the capital letter S in the top left corner of the display you would call LCD_Text(0,0,51);.

*For this to work in the correct orientation, you will to change a value in your initialization. Where you call writeCom( 0xC0 ) you will need to change it to writeCom( 0xC8 ).*

Actually I now do have some questions, because the ST7565R documentation is so difficult to follow...

how do i achieve a "Read Data" and a "Read Status" from a point of view of the control lines...

I am not sure how the code you have given relates to the table of commands, because the documents don't show the transitions required on the control pins to achieve them. ( and I am not entirely convinced by the timing diagram because it seems like a general setup?) Is it just a case of having the WR PIN in the opposite state? In which case for (7) Display data read I will need A0 to be HIGH, RD LOW, and WR HIGH... we never toggled RD before... should the WriteData and WriteCommand functions now make sure of the state of RD?

Of course... with my unidirectional level shifters... I wont be able to read the status of the pins... But I would like to know the correct approach for doing readData and readStatus

There are two read commands available. Status read, and Display data read. This is the only time you would need to toggle the /RD signal as opposed to the /WR signal. The way these signals work (how 8080 mode works) is after you have put a byte on the bus, you pull one low (active low signals, normally kept high; which one to pull low depends on if you want to write or read) and then bring it back high. This is why typically if never reading anything from the display, you can keep /RD tied high and only toggle /WR when needing to write. If you do need to read however, then you would just do the opposite. You would need /WR to be held high, while /RD is the signal that is toggled. The difference between the two read commands is the A0 signal. If this signal is low, then the controller will read the status when you toggle the /RD signal. If A0 is high, it will read the display data. As for your question about the write functions making sure of the state of /RD, you may do so if you wish, but it is not necessary. If after power on you simply set this signal high, you won't need to waste CPU cycles each time the function is called