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] Problem with LCD(JHD162A) interfacing with PIC18f25K22 microcontroller

Status
Not open for further replies.

freemanantony

Member level 4
Member level 4
Joined
May 19, 2010
Messages
70
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Chennai, India
Activity points
2,005
hi everybody,
i am trying to interface jhd162A lcd with pic18F25k22 microcontroller. Port A is used to connect lcd control as well as data lines. Initially i used port registers to write outputs but after reading through the forum i changed it to Lat . i am using internal oscillator INTOSC67 in config1 register as clock thus i can use RA6 and RA7 as GPIO and i have disabled all other analog functions of the port . But only weird characters are getting displayed in the LCD. Can anyone help me out on this issue

- - - Updated - - -

Code:
#pragma config FOSC = INTIO67   // Oscillator (LP,XT,HSHP,HSMP,RC,RCIO6,ECHP,    //INTIO7
                                //  ECHPIO6,INTIO67,INTIO7,ECMPIO6,ECLP,ECLPIO6)
#pragma config PLLCFG = OFF     // 4X PLL Enable
#pragma config PRICLKEN = OFF   // Primary clock enable
#pragma config FCMEN = OFF      // Fail-Safe Clock Monitor Enable
#pragma config IESO = OFF       // Internal/External Oscillator Switchover

// CONFIG2L
#ifdef __DEBUG
    #pragma config PWRTEN = OFF // Power-up Timer Enable
#else
    #pragma config PWRTEN = ON
#endif
#pragma config BOREN = SBORDIS      // Brown-out Reset Enable  (OFF,ON,NOSLP,SBODIS)
#pragma config BORV = 190       // Brown Out Reset Volt.(285,250,220,190)[V/100]

// CONFIG2H
#pragma config WDTEN = OFF     // Watchdog Timer Enable (OFF,NOSLP,SWON,ON)
#pragma config WDTPS = 32768    // Watchdog Timer Postscale Select (1:32768)

// CONFIG3H
#pragma config CCP2MX = PORTC1  // ECCP2 B output mux (PORTB3, PORTC1)
#pragma config PBADEN = OFF     // PORTB A/D Enable
#pragma config CCP3MX = PORTB5  // CCP3 MUX (PORTB5, PORTC6)
//#pragma config HFOFST = ON      // HFINTOSC Fast Start-up
#pragma config T3CMX = PORTC0   // Timer3 Clock input mux (PORTB5,PORTC0)
#pragma config P2BMX = PORTB5   // ECCP2 B output mux (PORTB5,PORTC0)
#ifdef __DEBUG
   #pragma config MCLRE = EXTMCLR  // MCLR Pin Enable (MCLR / RE3)
#else
   #pragma config MCLRE = INTMCLR
#endif

// CONFIG4L
#pragma config STVREN = ON      // Stack Full/Underflow Reset Enable
#pragma config LVP = OFF        // Single-Supply ICSP Enable
#pragma config XINST = OFF      // Extended Instruction Set Enable

// CONFIG5L
#pragma config CP0 = OFF        // Code Protection Block 0
#pragma config CP1 = OFF
//#pragma config CP2 = OFF
//#pragma config CP3 = OFF

// CONFIG5H
#pragma config CPB = OFF        // Boot Block Code Protection
#pragma config CPD = OFF        // Data EEPROM Code Protection

// CONFIG6L
#pragma config WRT0 = OFF       // Write Protection Block 0
#pragma config WRT1 = OFF
//#pragma config WRT2 = OFF
//#pragma config WRT3 = OFF

// CONFIG6H
#pragma config WRTC = OFF       // Configuration Register Write Protection
#pragma config WRTB = OFF       // Boot Block Write Protection
#pragma config WRTD = OFF       // Data EEPROM Write Protection

// CONFIG7L
#pragma config EBTR0 = OFF      // Table Read Protection Block 0
#pragma config EBTR1 = OFF
//#pragma config EBTR2 = OFF
//#pragma config EBTR3 = OFF

// CONFIG7H
#pragma config EBTRB = OFF      // Boot Block Table Read Protection*/

void hw_init()
{	
	
    //OSCCON = 0x3C;
    //OSCCON2 = 0x06;
    
	//PORTA =0x00;
    //LATA =0x00;
	//ANSEL = 0x00;
	//ANSELH = 0x00;
	TRISA=0x00;//  LCD O/P
	TRISB=0xEF;
	TRISC=0x80;
	
		ANSELA = 0X00;
        ANSELB = 0X00;
        ANSELC = 0X00;
        C1ON = 0;
        C2ON = 0;
        CM1CON0 =0X00;
        CM2CON0 = 0X00;
        CCP1CON = 0x00;
        CCP2CON = 0x00;
        CCP3CON = 0x00;
        CCP4CON = 0x00;
        CCP5CON = 0x00;
        VREFCON1 =0X00;
        VREFCON2 =0X00;
        VREFCON0 =0X00;
       // CVREN =0;
        //CVRCON = 0x00;
        CM1CON = 0x00;
        //CANCON =0X00;
        
	INTCON=0x00;    //Disable interrupts
	//OPTION |= 0x0F;	//1:2 prescaler			// PRESCALAR TO 1:256, WATCH DOG ENABLE ON 25-01-2013
	
//	OPTION_REG = 0x00;	//1:2 prescaler
	T0IE = 1;	//temporarily disable Timer0 interrupt 		// TIMER ENABLED ON 25-01-2013

//	WPUB=0xF0;//WEAK PULL-UP
//	IOCB=0x00;//INTERRUPT ON CHANGE
//	RBPU=0;	// PORTB PULLUP ENABLE
//	nRBPU=0;	// PORTB PULLUP ENABLE
		
	//TIMER
	T1CON=0x00;
	//TMR1CS=0;	//INTERNAL TIMER1 CLOCK
	T0CS=0;		//Timer0
	T2CON=0x7A;	//TIMER2(1:16 prescaler and 1:16 postscaler)
	CLRWDT();
	BRGH1 = 1;
	BRG161 =0;
	SPBRG =0x19;	// TO GENERATE BAUDRATE = 9600
	SPBRGH=0x00;
	SYNC1 = 0;	//ASYNCHRONOUS MODE
	SPEN1 = 0;	// SERIAL PORT ENABLE
	TXEN1=1;
	CREN1=1;
	TXIF=0;
	RCIF=0;

- - - Updated - - -

this is the initialization part of the code
 

Can you post a schematic of the LCD to PIC interface?

Also, please post your LCD source code routines.


BigDog
 

With these types of LCD displays, the minimum timing for initialisation and operation is critical.
I see that you are also initialising the UART. Are you using that to receive characters through that and displaying them on the LCD? The reason I ask is that I'm not sure your BAUD rate calculation is quite correct given the comments in the code. You are using the the default settings for the internal oscillator which means that Fosc is 1MHz. You state that you want 9600 BAUD and are setting BRGH to 1 and BRG16 to 0. Using the appropriate formula from Table 16-3 in the data sheet, I calculate that the SBRG value should be 5 and not 25. However this will give rise to a large error (which is one of the most common causes of 'weird characters' sent and received over a UART) and I suggest that you use BRGH set to 1 (as you have) and BRG16 set to 1 as well.
Susan
 

hi bigdoggurru and aussie susan,
i found out the problem, the problem was in the hardware the voltage in R/W pin of LCD was 1 V (neither 0 logic nor 1 logic)eventhough it was connected to ground through a resistor, now i connected that pin to ground stright and the voltage becomes zero and now the LCD is working fine. thank you guys for your time.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top