Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 6th July 2009, 06:59 AM   #1
Default lcd using pic18f452

Hi everyone

i have started pic hardware two weeks ago , before it i gone through much of it programming in assembly , since three days i m working on interfacing 14 pin lcd with ribbon connection , i m using sipmle program which is downloaded well into ic and progrm is burnt well ,with proper setting of configuration bits , when i interface the lcd it just giving some bullets which shows lcd is fine i m sending u my code and hope 4 ur reply since i m finding no way at there. thanx



LIST p=18F452 , F=INHX32, MM=OFF, N=0, ST=OFF , R=HEX
#Include P18F452.INC
CONFIG OSC=HS , OSCS=OFF
CONFIG WDT=OFF
CONFIG BORV=45, PWRT=ON, BOR=ON
CONFIG DEBUG=OFF, LVP=OFF, STVR=OFF
ORG 00h
LCD_DATA EQU PORTB
LCD_CTRL EQU PORTD
R2 EQU 0*2
R3 EQU 0*3
MYREG EQU 0*4
MTREG EQU 0*5
RS EQU RD0
RW EQU RD1
EN EQU RD2
CLRF TRISD
CLRF TRISB
BCF LCD_CTRL,EN
CALL LDELAY
MOVLW 0*38
CALL COMNWRT
CALL DELAY
MOVLW 0*0E
CALL COMNWRT
CALL DELAY
MOVLW 0*01
CALL COMNWRT
CALL DELAY
MOVLW 0*06
CALL COMNWRT
CALL DELAY
MOVLW 0*84
CALL COMNWRT
CALL DELAY
MOVLW A'P'
CALL DATAWRT
CALL DELAY
MOVLW A'A'
CALL DATAWRT
AGA BTG LCD_CTRL,0
BRA AGA
COMNWRT
MOVWF LCD_DATA
BCF LCD_CTRL,RS
BCF LCD_CTRL,RW
BCF LCD_CTRL,EN
CALL DELAY
BCF LCD_CTRL,EN
RETURN
DATAWRT
MOVWF LCD_DATA
BSF LCD_CTRL,RS
BSF LCD_CTRL,RW
BSF LCD_CTRL,EN
CALL SDELAY
BCF LCD_CTRL,EN
RETURN
SDELAY
MOVLW 0FF
MOVWF MYREG
ADAIN NOP
NOP
DECF MYREG,F
BNZ ADAIN
RETURN
LDELAY
MOVLW D'200'
MOVWF R2
AJAIN MOVLW D'250'
MOVWF R3
HERE NOP
NOP
DECF R3,F
BNZ HERE
DECF R2,F
BNZ AJAIN
RETURN
DELAY
MOVLW D'200'
MOVWF MTREG
AHAIN
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
DECF MTREG,F
BNZ AHAIN
RETURN
END
Attached Files
File Type: asm LCD56.asm (1.2 KB, 19 views)
einton is offline  
Old 6th July 2009, 07:09 AM   #2
Default

What is your oscillator frequency? An LCD requires a delay of about 5 to 10 ms for every command and a little more for data.What i do is use a longer delay and use one delay loop for all.
__________________
I just cant come up with a good one!
silvarblade is offline  
Old 6th July 2009, 07:14 AM   #3
Default

You have a couple of errors in your data and command write routines,

Code:
COMNWRT			 
		movwf	LCD_DATA 
		bcf	LCD_CTRL,RS
		bcf	LCD_CTRL,RW
		bsf	LCD_CTRL,EN	;was bcf
		call	DELAY
		bcf	LCD_CTRL,EN
		return
DATAWRT
		movwf	LCD_DATA
		bsf	LCD_CTRL,RS
		bcf	LCD_CTRL,RW	;was bsf
		bsf	LCD_CTRL,EN
		call	SDELAY
		bcf	LCD_CTRL,EN
		return
Mike.
Pommie is online now  
Old 7th July 2009, 03:16 PM   #4
Default lcd using pic18f452

thanx pommie
I did what u pointed , but still the things are not working at all , interestingly i m also gettting no any display when i m trying to simulate it on proteas , im using 10 Mhz crystal, i have also used it using single delay of 25 msec but it is also not working . i got blank this time , i think i have used correct config setting .

Last edited by einton; 7th July 2009 at 03:22 PM.
einton is offline  
Old 7th July 2009, 03:28 PM   #5
Default

You should try and find some working code that you can test your hardware with. If you post a schematic then people may be able to provide working code.

Mike.
Pommie is online now  
Old 7th July 2009, 05:08 PM   #6
Default

It may be the contrast pin is not at the correct voltage, hence the blank screen...

As suggested load some working code to test your hardware..
__________________
Eccentric millionaire financed by 'er indoors
Chippie is offline  
Old 7th July 2009, 07:49 PM   #7
Default

Hi, here is the code, the problem is that the delay is very small due to you using HS mode of the 18F452. Another problem is that you used PORTx for output when you should be using LATx registers.Here is the code and the attached simulation in Proteus.

Code:
LIST p=18F452;This ones for a 10MHz crystal.When you start        ;proteusD.C on the device and change the crystal to 10Mhz.
#Include P18F452.INC
CONFIG OSC=HS , OSCS=OFF
CONFIG WDT=OFF, LVP=OFF
ORG 00h
MOVLW 07
MOVWF T0CON
LCD_DATA EQU LATB
LCD_CTRL EQU LATD
RS EQU RD0
RW EQU RD1
EN EQU RD2
CLRF TRISD
CLRF TRISB
BCF LCD_CTRL,EN 
CALL DELAY 
MOVLW 0X38
CALL COMNWRT
CALL DELAY 
MOVLW 0X0E
CALL COMNWRT
CALL DELAY 
MOVLW 0X01
CALL COMNWRT
CALL DELAY 
MOVLW 0X06
CALL COMNWRT
CALL DELAY 
MOVLW 0X84
CALL COMNWRT
CALL DELAY 
MOVLW A'P'
CALL DATAWRT
CALL DELAY 
MOVLW A'A'
CALL DATAWRT
AGA BTG LCD_CTRL,3
BRA AGA


COMNWRT			 
		movwf	LCD_DATA 
		bcf	LCD_CTRL,RS
		bcf	LCD_CTRL,RW
		bsf	LCD_CTRL,EN	;was bcf
		call	DELAY
		bcf	LCD_CTRL,EN
		return
DATAWRT
		movwf	LCD_DATA
		bsf	LCD_CTRL,RS
		bcf	LCD_CTRL,RW	;was bsf
		bsf	LCD_CTRL,EN
		call	DELAY
		bcf	LCD_CTRL,EN
		return

DELAY:
MOVLW 4
MOVWF 0X20

AGAIN:

MOVLW 0FF
MOVWF TMR0H
MOVWF TMR0L
BCF INTCON,TMR0IF
BSF T0CON,TMR0ON

DELAY1:

BTFSS INTCON,TMR0IF
BRA DELAY1
BCF T0CON,TMR0ON
DECFSZ 0X20
BRA AGAIN
RETURN
END
Attached Files
File Type: zip lcd.zip (15.9 KB, 20 views)
File Type: asm LCD.asm (1.0 KB, 15 views)
__________________
Syed

Last edited by Wond3rboy; 8th July 2009 at 07:36 AM.
Wond3rboy is offline  
Reply

Tags
lcd, pic

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
pic18f452 butters Micro Controllers 2 15th May 2009 07:50 AM
pic18f452 ADC strong-storm2006 Micro Controllers 5 30th November 2008 08:14 AM
PIC18f452 with accelerometer erictham83 Micro Controllers 2 19th August 2006 08:44 PM
Pic18f452 yantheman Micro Controllers 1 4th May 2006 05:17 PM
PIC18F452 Timers mora Micro Controllers 1 2nd September 2005 10:53 AM



All times are GMT. The time now is 12:10 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker