Nothing on my LCD

domi2c

New member
Hello,

I have connected my CFAG320240-FMIT LCD on my microcontroller (HCS12) board (MC9S12DP256 precisely).
I have connected the CCFL module and I command the LCD in bit banging with Datas on PORTB and Signals on PORTA.
I've written functions to write on the LCD and compiled them
with ICC12. I inspired my work from a Hantronix doc (excuse me but it's in assembly and I understand it, not the C++) using a 80C751 microcontroller that I have worked with before.
I send a little bitmap (160 X 80 pixels) and a message (about 20 characters).
The LCD is lighted smoothly with a beautiful blue color but nor a letter neither a line appeared on it.

1) Does the LCD includes an oscillator or do I have to send a clock signal on the E pin of the LCD connector ? If yes, at which frequency ?

2) I have posted a message before (How to begin ...) and you replay proposing the test program on the parallel port of a PC. I don't want to do that and the program is in C++ that I don't understand. Would you, please, send me snippets of C code for interfacing with a microcontroller ?

3) I have read all the SED1335 docs and it's awful to me, would you help me please ?

Best regards

Merci beaucoup par avance

Jean Claude LUCOT:mad: :mad: :mad:
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.
 
Hello Jean Claude,

1) The LCD does have its own internal oscillator for refreshing the screen. The E signal is used as a strobe for the data bus. To write a command or data, the data is put on the bus port, and then the E signal is raised then lowered. The minimum E width (high) is 120 nS, and the write action occurs on the falling edge.

Have you initialized the display? You could post some of your code so we can see what you are trying to do.

2) You can download my C code sample from the 3rd Party Software forum,
https://forum.crystalfontz.com/showthread.php?s=&threadid=3619
Also, I can give you some samples of HCS12 code for the CFAX displays. Not the same controller chip, but the concept is the same. PM me your email addr if you want the code.

3) What particular things do you want help with?

P.S. Learning C++ would be useful, you should try it.
 
Last edited:

domi2c

New member
Hello Cosmicvoid,

Thanks for your help.
In my code, I maintain the E pin on high level. I will try to do what you said and see what 'll happen. And thanks for the threads in reference. I'll study it.
I am to post you my code at your own address.
Regards
Jean Claude
 

domi2c

New member
Hello Cosmicvoid,
I can't send my code to you directly so here it is :

Code:
//******************************************************************
// graph.c : fichier de fonctions nécessaires à l'affichage graphique
// sur afficheur CFAG320240-FMIT de Crystalfontz
// 320 X 240 pixels
// Commande en bit banging sur les ports A et B du µC.
//******************************************************************
// Pin 		symbole    brocheµC  Function
//
// 1   		Vss		   0v		 Masse 
// 2  		VDD		   5.0v		 Alimentation de la logique
// 3  		V0		   variable	 Tension de commande négative(~ -9.5v)
// 4  		E   	   PA.7		 Enable de la famille 6800   
// 5   		R/W		   PA.6		 Signal d'écriture de la famille 6800      
// 6   		A0		   PA.5		 R/W=0, A0=1 :Ecrit comm, A0=0 écrit data
// 					   			 R/W=1, A0=1 :Lit Etat,   A0=0 lit data
// 7  		Data0	   PB.0		 Data Bus     
// 8   		Data1      PB.1      Data Bus
// 9   		Data2      PB.2		 Data Bus     
// 10   	Data3      PB.3		 Data Bus     
// 11  		Data4      PB.4		 Data Bus     
// 12  		Data5      PB.5		 Data Bus   
// 13		Data6	   PB.6		 Data Bus 
// 14  		Data7	   PB.7		 Data Bus 
// 15  		/CS		   PA.4		 Chip Select, actif à l'état bas
// 16  		/RES	   PA.3		 Reset, actif à l'état bas 
// 17 		VEE		   -25v		 Sortie de tension négative interne 
// 18  		FGND	   			 Masse métallique                     
// 19  		Non connecté                        
// 20  		Non connecté                      
//-------------------------------------------------------------------
// jean Claude LUCOT le 31/07/2005
//******************************************************************

#include "graph.h"
#include <mc9s12dp256.h>

// msg1 : initialise le système
static unsigned char msg1[]= {0x30,0x87,0x07,0x27,0x39,
				              0xef,0x28,0x0,0xa1};
// msg2 : Scrolling							  
static unsigned char msg2[]= {0x0,0x0,0xef,0xb0,0x04,
				              0xef,0x0,0x0,0x0,0x0,0xa1};
// msg3 : Forme du curseur							  
static unsigned char msg3[]= {0x04,0x86,0xa1};
// msg4 : Paramètre de recouvrement
static unsigned char msg4[]= {0x01,0xa1};
// msg5 : Ecran on / off
static unsigned char msg5[]= {0x16,0xa1};
// msg6 : curseur sur page graphique
static unsigned char msg6[]= {0xb0,0x04,0xa1}; 
// msg7 : curseur sur page texte L=49 C=128
static unsigned char msg7[]= {0x31,0x02,0xa1};
// msg 8 : curseur sur page texte L=89 C=128 
static unsigned char msg8[]= {0x59,0x02,0xa1};
// msg9 : curseur sur page texte L=129 C=128 
static unsigned char msg9[]= {0x81,0x02,0xa1};
// msg10 : curseur sur page texte L=169 C=128 
static unsigned char msg10[]= {0xa9,0x02,0xa1};
// msg11 : efface la zone de texte
static unsigned char msg11[]=
         {0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
// 1200 caractères 0x20
		 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xa1};
// msg12 : fin de tableau
static unsigned char msg12[]= {0xa1};
// msg13 : curseur en position HOME
static unsigned char msg13[]= {0x0,0x0,0xa1};
// msg14 : 1ère ligne texte
static unsigned char msg14[]= {'E','S','S','A','I',' ','L','C','D',' ','G','R',
                        'A','P','H','I','Q','U','E',0xa1};
// msg15 : 2ème ligne texte
static unsigned char msg15[]= {'p','a','r',' ','J','e','a','n',' ','C','l','a',
                        'u','d','e',' ','L','U','C','O','T',0xa1};
// msg16 : 3ème ligne texte
static unsigned char msg16[]= {'L','A',' ','M','I','N','A','U','D','E','R','I',
                        'E',0xa1};
// msg17 : 4ème ligne texte
static unsigned char msg17[]= {'V','i','g','n','o','u','x',' ','s','u','r',' ',
                        'B','a','r','a','n','g','e','o','n',0xa1};
// titre : Image transmise
static unsigned char titre[]=
		 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
		 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
		 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
		 0x00,0x00,0x00,0x00,
// etc.,etc.
		 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
		 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
		 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
		 0x00,0x00,0x00,0x00,0xa1};
							  
void glcd_Init(void)
{
  	 DDRA |= 0xF8;		// Bit 3 à 7 du Port A en sortie
	 DDRB = 0xFF;		// Port B en sortie
	 
	 send_comm(0x40);	   // Set le système
	 send_mess_glcd(msg1); // paramètres d'initialisation
	 send_comm(0x44);
	 send_mess_glcd(msg2); // paramètre scrolling
	 send_comm(0x5d);
	 send_mess_glcd(msg3); // forme du curseur
	 send_comm(0x4c);	   // direction de déplacement du curseur

}

void main(void)
{
 	 glcd_Init();
	 send_comm(0x5a);	   // hauteur
	 send_mess_glcd(titre);	  // envoie l'image
	 send_comm(0x5b);		  // surimpression
	 send_mess_glcd(msg4);	  // paramètres de surimpression
	 send_comm(0x59);		  // Ecran on / off
	 send_mess_glcd(msg5);	  // paramètres écran
	 clrtextram();			  // efface mémoire texte
	 send_comm(0x46);		  // positionne curseur
	 send_mess_glcd(msg6);	  // paramètres du curseur
	 send_comm(0x42);		  // mwrite
	 send_mess_glcd(msg12);
	 send_comm(0x46);		  // positionne curseur
	 send_mess_glcd(msg7);	  // paramètres du curseur
	 send_comm(0x42);		  // mwrite
	 send_mess_glcd(msg14);
	 send_comm(0x46);		  // positionne curseur
	 send_mess_glcd(msg8);	  // paramètres du curseur
	 send_comm(0x42);		  // mwrite
	 send_mess_glcd(msg15);
	 send_comm(0x46);		  // positionne curseur
	 send_mess_glcd(msg9);	  // paramètres du curseur
	 send_comm(0x42);		  // mwrite
	 send_mess_glcd(msg16);
	 send_comm(0x46);		  // positionne curseur
	 send_mess_glcd(msg10);	  // paramètres du curseur
	 send_comm(0x42);		  // mwrite
	 send_mess_glcd(msg17);
	 while(1)
	 {
	 ;
	 }
}

void send_comm(unsigned char octet)
{
 	 PORTA |= 0xf8;	 	   // A0 à 1 -> commande
	 PORTB = octet;
	 PORTA &= 0xef;		   // CS à 0
	 PORTA &= 0xaf; 	   // R/W à 0
	 PORTA |= 0xe8;
	 PORTA |= 0xf8;
}

void send_data(unsigned char octet)
{
 	 PORTA &= 0xd8;		   // A0 à 0 -> donnée
	 PORTB = octet;
	 PORTA &= 0xc8;		   // CS à 0
	 PORTA &= 0x88; 	   // R/W à 0
	 PORTA |= 0xc8;
	 PORTA |= 0xd8;
}

void send_mess_glcd(unsigned char *message)
{
 	 char car = 0;
	 
	 while(message[car] != 0xa1)
	 {
	  	 send_data(message[car]);
		 car++;
	 }
}

void clrtextram(void)
{
 	 send_comm(0x46);
	 send_mess_glcd(msg13);
	 send_comm(0x42);
	 send_mess_glcd(msg11);
	 send_comm(0x46);
	 send_mess_glcd(msg6);
}
Thanks in advance

Jean Claude
 
I have looked at your code, but I have not analysed your initialization strings (you are right that the data sheet is very complicated!), because I see a very serious error in your send_comm() and send_data() functions. You are not using the E signal at all, so nothing is being sent to the display.

Also, unless you have something else connected to the data bus port, you don't need to change the CS signal, just tie it low. You could leave the R/W low normally also, and only change it if you have a 'read' function.

The signal port could be set to 0x28 normally.

Code:
void send_comm(unsigned char octet)
{
 	PORTA = 0x28;	 	   // E = 0, RW = 0, A0 = 1 -> command
	PORTB = octet;
	PORTA |= 0x80;	 	   // E = 1
	// delay here for 120 nS
	PORTA &= 0x7F;	 	   // E = 0
}

void send_date(unsigned char octet)
{
 	PORTA = 0x08;	 	   // E = 0, RW = 0, A0 = 0 -> data
	PORTB = octet;
	PORTA |= 0x80;	 	   // E = 1
	// delay here for 120 nS
	PORTA &= 0x7F;	 	   // E = 0
}
Try this and let me know your result.

Edit: I don't see any use of the RESET line either. Before your first command in the initialization, the RESET line should be set low for a few mS, then leave it high.
 
Last edited:

domi2c

New member
Hello Cosmicvoid

Very kind of you to help me like this.

So, I've tied CS to low and modify the code like you said.
To test it, I've made a little code that just consist of a loop which uses the new "send_comm" function to see all signals on PORTA and the value on PORTB. Doing this, I've found that I have a short-circuit between PB.7 and PB.6 in the flat cable and repared it. I've also seen that I have now a good 140 ns E positive pulse.
I dare say I now have a correct hardware.

I have introduced a 4ms reset negative pulse in my glcd_Init routine and tried again to put things on my LCD.

I have nothing at all. But I can run the code step by step and It's working good.
At the beginning of the glcd_Init routine, I have two instructions as DDRA = 0xf8 and DDRB = 0xff to turn the Ports A and B as outputs.
When these instructions occurs, I have two horizontal lines of all the width of the screen on the LCD.

So, I think there must be errors in the configuration strings I send to the LCD, you know ?

I'm going to simplify my code and just try to put a single character on the screen and see what will happen.

Regards

Jean Claude
 
Jean,

It is good that you have the tools to troubleshoot your project. Seeing the signals on a scope is the best way to be sure of what is happening. And stepping through the code makes debugging easier.

I will take another look at your initialization strings, to see if I can find a problem, although I have never used this display, so I will have to learn as I go.

One other idea: are you sure the Vo voltage is correct? The data sheet says Vdd-Vo is (typical) 24 volts, so Vo should be about -19 volts. You should be able to turn the contrast pot, and see the screen change from dark to light. The comment in your code says "Tension de commande négative(~ -9.5v)", which may not be enough.
 
Jean,
I have looked more at your code. I only see one place that seems wrong:
Code:
 	 glcd_Init();
	 send_comm(0x5a);	   // hauteur
	 send_mess_glcd(titre);	  // envoie l'image
The 0x5A command expects one byte of data to follow, but the "static unsigned char titre[]" is at least 40 bytes long.

By the way, I have a suggestion for sending the long arrays of the same data byte... use a for() loop:

instead of "send_mess_glcd(msg11);", do this: (you can avoid the large array declaration)
Code:
for (a = 0; a < 1200; a++)
{
 send_data(0x20);
}
Since I don't know what your screen design is, I can not judge whether your numbers are good or not. Have you looked at section 15 and 16 of the SED1335 data sheet (at page 65)? There are some samples of the initialization sequences that, presumably, should work. At least to see if the display is functioning correctly. Also, see that the RESET signal requires a 3 mS delay after going high, before doing the init.

You might try making the width of the E pulse longer, perhaps 250 nS, just to be sure there is not a timing issue when writing the data. I think it will not slow your program too much :D.

Have you made any progress?
 

domi2c

New member
Hi Cosmicvoid

I 've had the same ideas as yours.

I have modify entirely the glcd_init routine using the page 65 example of Epson's doc. it's a bit hard for the values in the SET section to send, like the 4th and 5th bytes which need the internal Fosc, the refreshment frequency and all. But that's done. And I will try to put EPSON on the screen and reverse the video like they do. It's identically the same code as theirs.

Also I have transform the transmitting of the big array of space characters in a for structure to clear the memory screen blocks, I prefer like that.

I must modify, like you say, the reset timing high before the init session and increase the E pulse time and try again.

Aw, I have turned the VDD - VO voltage to -24V and in that case, I have a little stripe (a few pixels) all around the screen and the middle zone became very clear (almost white) and blinked hard. Like a speedy scroll.

Now, as you're sleeping maybe, (it's 9 AM in France), I'm going to try that and let you know afterwards.

Have good dreams

Jean

PS : I think that Crystalfontz sheet of the CFAG320240C-FMIT is a little bit thin to make this stuff works properly. I haven't count my hours on this, but I'm glad it's not for job. I think they will fire me.;)
 

domi2c

New member
Hi,

I've made all the changes I said and, Man, I 've written my name on this stuff.

But my screen seemed parted in a upper and a lower panel. However I put 0 in W/S in the SET session. And there are vertical lines seperated by 8 pixels I think.
In the lower part of each panel ther are about 20 pixels high stripe of jerk.

I now think there are parameters to change one by one and see what occurs.

I have tried to take a picture of the screen but it was not clear enough for you to see. Too bad.

Thanks one more for all your help.

Regards

Jean
 

domi2c

New member
Hello Cosmicvoid,

Now, I have put the right parameters.
There was a problem in the type of layers : 1 to be text and 2 to be graphic. In fact I cleared the two layers as text and that was the reason of the vertical lines.

All is clear now and the text on the LCD is correct.

Now I can send the very text and value I will for the purpose of my weather station.

Without your help I think I would let it go.
Thanks a lot

Jean Claude
 
Jean,

Excellent! Glad you are able to make the display work.

I know it can be very frustrating to work with a new complex component, and you can't figure out why its not working, so you have to go through the experiments to "re-invent the wheel". But now you are on the road. (is that too corny? :rolleyes: )
 
Top