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.

LCD code is not working...

Status
Not open for further replies.

kvrajasekar

Junior Member level 3
Joined
Sep 18, 2008
Messages
28
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,283
Activity points
1,517
mikroc: not enough ram

Hi,

I am using CDM16216B LCD to interface with 16f72.But i didnt get anything on LCD.Please kindly reply me,my code is here.


list p=16f72 ;PIC16f72 is the target processor
INCLUDE "P16f72.INC"
;------------------------------------------------------------------------------------
; PORTA control bits


__CONFIG _PWRTE_ON & _XT_OSC & _WDT_OFF ; configuration switches
#DEFINE LCD_RS PORTA, 0 ; RA0 is RS line of LCD
#DEFINE LCD_E PORTA, 1 ; RA1 is E line of LCD
; RC0-RC3 are D4-D7 of LCD
Temp equ 0x20
delay1 equ 0x21

org 0x00
goto start


;------------------------------------------------------------------------------------
start
bsf STATUS, RP0 ; Bank1
errorlevel 1,-302 ; Don't warn me about bank 1

movlw b'00000000' ; Defining input and output pins
movwf TRISA ; Writing to TRISA register
movlw b'00000000' ; Defining input and output pins
movwf TRISB ; Writing to TRISB register 1-input,0-output
movlw b'00000000'
movwf TRISC
movlw b'10000110' ; TMR0,prescaler-128
movwf OPTION_REG
movlw 0x07
movwf ADCON1
bcf STATUS, RP0 ; Bank0
clrf PORTA ; potra,portb initially set to low
clrf PORTB
clrf PORTC



call lcd_init
bsf PORTA,5 ; Buzzer
call delay_0.5s
bcf PORTA,5

call disp_main
movlw 0xC1
call disp_cmd
btfsc PORTB,4 ;UPS RDY
call disp_ups


lcd_init

movlw 0x28 ; 4 bit, 2 Line, 5x7 font
call disp_cmd
call delay
; movlw 0x10 ; display shift off
; call disp_cmd
; call delay
movlw 0x0E ; increment cursor
call disp_cmd
call delay
movlw 0x01 ; Clear the Display RAM
call disp_cmd
call delay ; Note, Can take up to 4.1 msecs

movlw 0x06 ; move the cursor to begining
call disp_cmd
call delay
; movlw 0x0C ; display on cursor off
; call disp_cmd
; call delay
return
delay
movlw d'236' ;2.5ms delay
movwf TMR0
loop1 btfss INTCON,2
goto loop1
clrf INTCON ; if overflow occur,clear INTCON
return
d
;------------------------------------------------------------------------------------
;Display command for 4 bit LCD

disp_cmd ; Send the Instruction to the LCD
movwf Temp ; Save the Temporary Value
swapf Temp, w ; Send the High Nybble
bcf LCD_RS ; RS = 0
call nibbleout
movf Temp, w ; Send the Low Nybble
bcf LCD_RS
call nibbleout
return
;------------------------------------------------------------------------------------
;sending ASCII character to LCD
disp_write
; addlw '0' ; Send nbr as ASCII character ; Send the Character to the LCD
movwf Temp ; Save the Temporary Value
swapf Temp, w ; the High Nybble
bsf LCD_RS ; RS = 1
call nibbleout
movf Temp, w ; Send the Low Nybble
bsf LCD_RS
call nibbleout
return
;------------------------------------------------------------------------------------
;sending lower and upper nibble
nibbleout ; Send a nibble to the LCD
movwf PORTC
bsf LCD_E
call delay
bcf LCD_E
nop
nop
return

disp_main


movlw 'M' ; output 'MAIN'
call disp_write
movlw 'A'
call disp_write
movlw 'I'
call disp_write
movlw 'N'
call disp_write

movlw ' '
call disp_write
movlw 'N'
call disp_write
movlw 'O'
call disp_write
movlw 'R'
call disp_write

return

end
 

working lcd contrast code

did you see the dark lcd characters if not please check your wiring.
and if your controller of your lcd is overheating stop the power supply because it may damage your lcd.
 
Thank you for the response.

I didnt get any characters as you mentioned(dark characters),only backlight is ON(it is looking bright).

i will give you the pin connections what i did,I have used 2.5ms delay to send the command.will this delay is sufficient or i have to increase the delay.and contrast voltage is sufficient?

Please reply me.

1 - gnd
2- - +5v
3 contrast - +3v
4 -reset (RA0)
5 - gnd
6 - Enable(RA1)
7,8,9,10 - no connection
11,12,13,14 - data(RC0-RC3)
15 - gnd
 

Hi,
1. Try and adjust LCD voltage (contrast) using a pot., a very common problem.
2. Check initiation of timer carefully again.
3. Where does the code go to from:

" call disp_ups "

Regards,
Laktronics
 

2.5ms is not enough,try to code for lcd initilalization time(about 100ms) and then pls check if the wiring is not reverse
i mean some lcd are starting from 14.ground to 1 and so on...
but most of them have backlight at 15 and 16
 

Thanks for your points.

i will change the delay and LCD contrast,then get you back.Is it necessary to call lcd initialization when ever wnat to display a new character?or i can just call the display RAM address?

Can i use interrupt for LCD routine. i have doubt using interrrupt for LCD routine,
because it takes long time to come out of interrupt loop.correct me if i am wrong?
 

hai ,

if you using pic series then u can us compilers with full fledged mikroE softwares in three 1. using basic language 2. using python 3. using c programme(recomended ) download for the web site mikroC software through search google.com
 

Hi,
Long delays are only required for initial poweron settling and for the first few commands for init. As per one of the user Manuals, most of the commands require only 40usec. delay after init . Only two commands Clr Display and Return Home takes 1.64 msec. Enable pulse width is under one micro sec.and delay cycle time for two byte loading is only one usec. It is better to refer the User Manual of your display and trim delays as required.
Init is required only once on Poweron.

Regards,
Laktronics
 

When i used 8 bit,my code is working properly,but my 4 bit code is not working.

i used the command for 4 bit interface is,

movlw 0x28
call disp_cmd

is any command s required before this command?Please help me.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top