Almost got my CFAG12864B-TMI-V working

dodge55

New member
I gotten everything but the READ_DISPLAY_DATA command to work properly. Is there a code snippet that shows this 'dummy read' that needs to be done? I have done a WRITE_DISPLAY_DATA (set to 0xff) (which turns an entire column on), and reset the Y address back one, and I cannot get the proper read result (always reads 00, instead of FF). Under READ_DISPLAY, the 'refer to the explanation of output register in "Function of each Block"' is a mystery in the 'datasheet'.

Sutton
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.
 

CF Tech

Administrator
Sutton:

I have not writen code to read the data on the CFAG12864B series.

I would imagine it would be a lot like reading the busy bit.

Can you post your read routine, and I'll see if I can spot anything?
 

dodge55

New member
READ_DISPLAY_DATA on CFAG12864B-TMI-V

This code doesn't work, but I don't know why, since there is no real explanation in the datasheet of the proper read procedure. It does mention a 'dummy read', but that's all.
Code:
         Set_DI;
         Set_RW;
         Set_E;
         delay(MS,1);
         rawdata = IO1PIN;      // dummy read the Data lines
         Clr_E;
         delay(MS,1);
         Set_E;
         delay(MS,1);
         rawdata = IO1PIN;      // read the Data lines
         Clr_E;
Setting the Display to 0xFF in any location, resetting the Y address back, and reading display results in 0x00.

Sutton
 

CF Tech

Administrator
Are you setting the port pins to "input" from the microcontroller's point of view?
Code:
         Set_DI;
         Set_RW;
[COLOR="Red"]>> Need to set the processor's port to an input here[/COLOR]
         Set_E;
         delay(MS,1);
         rawdata = IO1PIN;      // dummy read the Data lines
         Clr_E;
         delay(MS,1);
         Set_E;
         delay(MS,1);
         rawdata = IO1PIN;      // read the Data lines
         Clr_E;
[COLOR="Red"]>> Need to set the processor's port back to an output here[/COLOR]
For instance, here is the read routine from this page showing KS0108 code for an AVR (red code indicates changing port direction):
Code:
00156 u08 glcdControlRead(u08 controller)
00157 {
00158     register u08 data;
00160     cli();
00161     glcdBusyWait(controller);       // wait until LCD not busy
00162     cbi(GLCD_CTRL_PORT, GLCD_CTRL_RS);
00163     [COLOR="Red"]outb(GLCD_DATA_DDR, 0x00);[/COLOR]
00164     sbi(GLCD_CTRL_PORT, GLCD_CTRL_RW);
00165     sbi(GLCD_CTRL_PORT, GLCD_CTRL_E);
00166     asm volatile ("nop"); asm volatile ("nop");
00167     asm volatile ("nop"); asm volatile ("nop");
00168     asm volatile ("nop"); asm volatile ("nop");
00169     asm volatile ("nop"); asm volatile ("nop");
00170     data = inb(GLCD_DATA_PIN);
00171     cbi(GLCD_CTRL_PORT, GLCD_CTRL_E);
00172     cbi(GLCD_CTRL_PORT, GLCD_CTRL_RW);
00173     [COLOR="Red"]outb(GLCD_DATA_DDR, 0xFF);[/COLOR]
00174     sei();
00181     return data;
00182 }
EDIT: I came across this site:

http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/glcd_dcf77/index.html

that has some KS0108/KS0107 code for a Philips LPC2000 ARM7TDMI ARM processor. That might be a good reference for your project.
 

dodge55

New member
Perfect answer. That was the problem. However, the 320 ns delay time is not enough. I had to put a 2 ms delay between reads to ensure that the second read was the correct value. Even 1 ms was not enough sometimes.

Sutton
 
Top