Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Help for the programation of a pic 18F47J53 with an LCD (SED1520)

Status
Not open for further replies.

Laweack

Newbie level 6
Joined
Apr 27, 2012
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,367
Hello everybody, i'm a new user of pic and i tried to program a pic to control an lcd.

The pic is a 18F47J53 ( starter kit )
The LCD is a BTHQ 100032V-FSTF-LEDwhite W.C. using SED1520

So i start to program it on MPLAB IDE and i have already some difficulties :s

I connected differents pin on the LCD : On the PORTD i have connected DB0 to DB7 and on the PORTB i have connected E2,E1,A0 and R/W respectivly on the bit 4 , 5 , 6 and 7.

I have made a C code too :
Code:
#include <stdio.h>
#include <stdlib.h>
#include <p18f47j53.h>
#include <GenericTypeDefs.h>
#include <pconfig.h>
#include <io.h>



//Prototype des fonctions

void Display(int Status);              
void Display_Start_Line(int ligne);
void Column_Address(int colonne);
void SetPage(int page);				
void Write_Display(int Line);
void ADC_Select(int Output);
void DutyCycle(int Switch);
void Static_Drive(int Drive);
void End();
void Delay();





void Delay()
{
	int i;

	for(i=0; i<100; i++);
}




void Display(int Status)		// attention statut = 0 ou 1
{
	static int DATA;

	DATA=0xAE ;// Status;		// On effectue un ou avec le statut permettant dobtenir les deux choix possibles soit D7->D0 = AE ou AF 
	//PORTD=DATA;
	//PORTB=0x00; 			// A0 = Bit 0
					// R/W 	=  Bit 1
					// E2 	=  Bit 2 
					// E1	=  Bit 3 
	PORTB=0x90;			// On initialise le portB avec A0 = 0, R/W = 1 , E1 = 1 et E2 = 0 ( Controle de la partie gauche de l'écran )
	PORTD=DATA;			// On ecrit la bonne sequence ds le portD


	PORTB=0xA0;			// On initialise le portB avec A0 = 0, R/W = 1 , E1 = 0 et E2 = 1 ( Controle de la partie droite de l'écran )
	PORTD=DATA;	


        PORTD=0x00;			// On reinitialise les ports a la valeur 0 
	PORTB=0x00;

}

void Display_Start_Line(int ligne)	// attention ligne compris entre 0 et 31
{
	static int DATA;

	DATA=0xC0 | ligne ;		// On effectue un ou avec la variable ligne (mot de 5bits) permettant dobtenir la combinaison definissant une des 32 lignes  
	PORTD=DATA;
	PORTB=0x00; 			// A0 = Bit 0
					// R/W 	=  Bit 1
					// E2 	=  Bit 2 
					// E1	=  Bit 3 
	PORTB=0xA0;			// On initialise le portB avec A0 = 0, R/W = 1 , E1 = 1 et E2 = 0 ( Controle de la partie gauche de l'écran )
	PORTD=DATA;			// On ecrit la bonne sequence ds le portD
	Delay();

	PORTB=0x90;			// On initialise le portB avec A0 = 0, R/W = 1 , E1 = 0 et E2 = 1 ( Controle de la partie droite de l'écran )
	PORTD=DATA;
	Delay();	


	PORTD=0x00;			// On reinitialise les ports a la valeur 0 
	PORTB=0x00;

}





void Column_Address(int colonne)  // attention colonne compris entre 0 et 79
{
	static int DATA;

	DATA=0x00 | colonne ;		// On effectue un ou avec la variable colonne (mot de 7bits) permettant dobtenir la combinaison definissant une des 79 colonnes 
	PORTD=DATA;
	PORTB=0x00; 			// A0 = Bit 0
					// R/W 	=  Bit 1
					// E2 	=  Bit 2 
					// E1	=  Bit 3 
	PORTB=0xA0;			// On initialise le portB avec A0 = 0, R/W = 1 , E1 = 1 et E2 = 0 ( Controle de la partie gauche de l'écran )
	PORTD=DATA;			// On ecrit la bonne sequence ds le portD
	Delay();

	PORTB=0x90;			// On initialise le portB avec A0 = 0, R/W = 1 , E1 = 0 et E2 = 1 ( Controle de la partie droite de l'écran )
	PORTD=DATA;
	Delay();	


	PORTD=0x00;			// On reinitialise les ports a la valeur 0 
	PORTB=0x00;
}


void Page(int page)			// attention page compris entre 0 et 3 
{
	static int DATA;

	DATA=0x00 | page ;		// On effectue un ou avec le nummero de la page nous permettant de nous placer sur la bonne page 
	PORTD=DATA;
	PORTB=0x00; 			// A0 = Bit 0
					// R/W 	=  Bit 1
					// E2 	=  Bit 2 
					// E1	=  Bit 3 
	PORTB=0xA0;			// On initialise le portB avec A0 = 0, R/W = 1 , E1 = 1 et E2 = 0 ( Controle de la partie gauche de l'écran )
	PORTD=DATA;			// On ecrit la bonne sequence ds le portD
	Delay();

	PORTB=0x90;			// On initialise le portB avec A0 = 0, R/W = 1 , E1 = 0 et E2 = 1 ( Controle de la partie droite de l'écran )
	PORTD=DATA;
	Delay();	


	PORTD=0x00;			// On reinitialise les ports a la valeur 0 
	PORTB=0x00;
}

void DutyCycle(int Switch)		// attention Switch = 0 ou 1
{
	static int DATA;

	DATA=0xA8 | Switch;		// On effectue un ou avec la variable switch permettant dobtenir les deux choix possibles soit D7->D0 = AE ou AF 
	PORTD=DATA;
	PORTB=0x00; 			// A0 = Bit 0
					// R/W 	=  Bit 1
					// E2 	=  Bit 2 
					// E1	=  Bit 3 
	PORTB=0xA0;			// On initialise le portB avec A0 = 0, R/W = 1 , E1 = 1 et E2 = 0 ( Controle de la partie gauche de l'écran )
	PORTD=DATA;			// On ecrit la bonne sequence ds le portD
	Delay();

	PORTB=0x90;			// On initialise le portB avec A0 = 0, R/W = 1 , E1 = 0 et E2 = 1 ( Controle de la partie droite de l'écran )
	PORTD=DATA;
	Delay();	
	Delay();	


	PORTD=0x00;			// On reinitialise les ports a la valeur 0 
	PORTB=0x00;
}

void ADC_Select(int Output)		// attention Output = 0 ou 1
{
	static int DATA;


	DATA=0xA0 | Output;		// On effectue un ou avec la variable Output permettant dobtenir les deux choix possibles soit D7->D0 = AE ou AF 
	PORTD=DATA;
	PORTB=0x00; 			// A0 = Bit 0
					// R/W 	=  Bit 1
					// E2 	=  Bit 2 
					// E1	=  Bit 3 
	PORTB=0xA0;			// On initialise le portB avec A0 = 0, R/W = 1 , E1 = 1 et E2 = 0 ( Controle de la partie gauche de l'écran )
	PORTD=DATA;			// On ecrit la bonne sequence ds le portD
	Delay();

	PORTB=0x90;			// On initialise le portB avec A0 = 0, R/W = 1 , E1 = 0 et E2 = 1 ( Controle de la partie droite de l'écran )
	PORTD=DATA;
	Delay();	
	Delay();	


	PORTE=0x00;			// On reinitialise les ports a la valeur 0 
	PORTB=0x00;
}

void End()
{
	PORTD=0xEE;
	PORTB=0x00; 			// A0 = Bit 0
					// R/W 	=  Bit 1
					// E2 	=  Bit 2 
					// E1	=  Bit 3 
	PORTB=0xA0;			// On initialise le portB avec A0 = 0, R/W = 1 , E1 = 1 et E2 = 0 ( Controle de la partie gauche de l'écran )
	PORTD=0xEE;			// On ecrit la bonne sequence ds le portD


	PORTB=0x90;			// On initialise le portB avec A0 = 0, R/W = 1 , E1 = 0 et E2 = 1 ( Controle de la partie droite de l'écran )
	PORTD=0xEE;


	PORTD=0x00;
	PORTB=0x00;
}

void Write_Display(int Line)
{
	
	static int DATA;


	DATA=0x00 | Line ;		// On effectue un ou avec la variable line permettant dobtenir le mot que l'on voulait ecrire 
	PORTD=DATA;
	PORTB=0x00; 			// A0 = Bit 0
					// R/W 	=  Bit 1
					// E2 	=  Bit 2 
					// E1	=  Bit 3 
	PORTB=0x90;			// On initialise le portB avec A0 = 0, R/W = 1 , E1 = 1 et E2 = 0 ( Controle de la partie gauche de l'écran )
	PORTD=DATA;			// On ecrit la bonne sequence ds le portD


	PORTB=0xA0;			// On initialise le portB avec A0 = 0, R/W = 1 , E1 = 0 et E2 = 1 ( Controle de la partie droite de l'écran )
	PORTD=DATA;		


	PORTD=0x00;			// On reinitialise les ports a la valeur 0 
	PORTB=0x00;

}

void Static_Drive(int Drive)
{
	static int DATA;

	DATA=0xA4 | Drive;
	PORTD=DATA;
	PORTB=0x00; 			// A0 = Bit 0
					// R/W 	=  Bit 1
					// E2 	=  Bit 2 
					// E1	=  Bit 3 
	PORTB=0x90;			// On initialise le portB avec A0 = 0, R/W = 1 , E1 = 1 et E2 = 0 ( Controle de la partie gauche de l'écran )
	PORTD=DATA;			// On ecrit la bonne sequence ds le portD


	PORTB=0xA0;			// On initialise le portB avec A0 = 0, R/W = 1 , E1 = 0 et E2 = 1 ( Controle de la partie droite de l'écran )
	PORTD=DATA;	

//	PORTE=0x00;
//	PORTB=0x00;
}


void main (void)
{
	
	TRISD = 0;
    TRISB = 0;

	PORTB = 0x00;
	PORTD = 0x00;
	
	DutyCycle(0x00);
	Display(0x00);
	Display_Start_Line(0x00);
	Static_Drive(0x00);
	Column_Address(0x03);
	Page(0x03);
	ADC_Select(0x00);
	Write_Display(0xFF);



}
(Commentaries are in french )


I take this code on the post : https://www.edaboard.com/threads/97884/

and i made modification because i didnt find the same value for the configuration of the differents ports but with this code all of the line of my LCD are on and i dont understand why :s This is the first time i program a pic and i really want to make the LCD works ! i dont know if i put all the necessary librairies but apparently i did..


Thx for your answers if you have some ideas (and sorry for my bad english ) :)
 

Do you think its better to program all the port B in one time by
Code:
	PORTB = 0b10100000;	// Prise en compte de la commande sur la partie gauche car front montant sur E1
	//Delay();
 	PORTB = 0b10110000;	// ¨"" sur la partie droite car front montant sur E1
or to use the function : LATBbits.LATB4 = 1; For example to set a bit and after an other ?


The lack of answer(s) disappoint me so much :(
 
Last edited:

Thanks for the answer L.O.L i have find the solution by myself if someone need it just ask.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top