Charge Pump / Optimize Contrast
Improving the contrast on the S128240D.
The code from the displayTech site is a starting point, but many improvements can be made.
The most important improvement I found was the contrast.
Lets start with the raw code:
http://www.displaytech-us.com/pdf/Sample%20Code/128240d-testprogram-080702.txt
If you use this with the S128240D, the display contrast may look a bit 'faded' or 'light'.
But this can be improved considerably the use of the 'partial display command' in just three lines of extra code!
Add the command to partially display lines 16 through 143 between ext=0 and display_on at the end of the 'initial' function.
Here is the original end of the 'initial(void)' function:
wcom(0x30,0); //ext=0
wcom(0xaf,0); //display on
delay3(100);
}
Here is the modified end of the 'initial(void)' function:
wcom(0x30,0); //ext=0
////////////////////
//start of new lines
wcom(0xa8,0); //set a partial display...
wcom(4,1); //...from block 4 (i.e. Starting at line 16)
wcom(35,1); //...through block 35 (i.e. ending at line 143)
//end of new lines
////////////////////
wcom(0xaf,0); //display on
delay3(100);
}
So why does this work?
The display has a 'visible' area of 128 lines x 240 columns.
However the controller can drive 160 x 255.
The display lines 0..127 are wired to the controller's lines 16 through 144.
If you use the original code, then the controller is trying to drive lines 0 through 160.
I.e. it tries to drive phantom lines 0..15 and 145..160.
Driving these phantom lines takes power from the controller's charge pump, and decays the voltage, giving a 'faded' appearance.
You still get the full 128 lines of the LCD - they are just mapped to the controllers lines 16..143
Perhaps i am missing some trick here, but my understanding is that the display uses controller lines 0-63, and 80-143. Refer P8 of the display datasheet.
ie "The display lines 0..127 are wired to the controller's lines 16 through 144" is incorrect...
Setting the code as above would blank out 16 lines of useable display...
Ah, there is a trick to all of the above after all. It all depends on the setting of COMSCN, as the Partial Display command PTLIN affects the RAM address, rather than the COM scan line address.
If you have COMSCN as 0, (0-79, 80-159), then the used RAM address is 0-63, 80-143.
If you have COMSCN as 2, (79-0, 80-159), then the used RAM address is 16-143.
Hi Brenhale
It looks like you've worked things, but perhaps a more explanation is in order.
A bit of terminology may help resolve the differences between:
* controller (memory) lines
* controller commons
* viewable area lines
The display controller has internal memory - this is where the programmer writes data for display.
This internal memory is mapped through to the display controller's output pins - the commons and segments.
These commons and segments are connected to the LCD's viewable area.
The S128240[C/D] has commons 0..63 and 80..143 connected to the viewable area of the LCD.
Commons 64..79 and 144..159 are not connected.
This is fixed in the manufacture of the LCD and cannot be changed through the command API calls.
What we do have control of is the mapping of the memory lines to the commons.
When the display is initialized per the DisplayTech example (1/144 duty, FPC at the top), then display memory lines 16 through 143 are mapped to viewable area lines 0..127.
So, a programming model would view (the controller memory) lines 16 through 143 are mapped to the viewable area of the display lines 0..127.
Writing to lines 0..15 and 128..159 would not be viewable on the LCD.
Martin