Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

write to lcd module please help

Status
Not open for further replies.
Code:
	CALL	DELAY10ms
	CALL	DELAY10ms
	MOVLW	h'38'
	CALL	KOMUTYAZ
	MOVLW	h'0C'
	CALL	KOMUTYAZ
	MOVLW	h'06'
	CALL	KOMUTYAZ
	MOVLW	h'01'
	CALL	KOMUTYAZ
	MOVLW	h'08'
	CALL	KOMUTYAZ
	MOVLW	h'53'		;S
	CALL	VERIYAZ
	MOVLW	h'41'		;A
	CALL	VERIYAZ
	MOVLW	h'02'
	CALL	KOMUTYAZ

Your init sequence seems very short.
 
Last edited:
which one is short? period of silence time ? or my program is short ( means I have to put some additional code else)?
 
Hello Amerotke,
Have a look at the 2 attached pdf docs. You can test your lcd using the circuits in there.
 

Attachments

  • lcd1.pdf
    240.7 KB · Views: 271
  • lcd2.pdf
    159.1 KB · Views: 152
A quick look at your code shows that you are setting the E flag, then moving the data to PORTB, then clearing the E flag. You must move the data to PORTB first, then set E, then reset E.

Mike
 
That makes sense Mike, if the E is being strobed at the wrong time then the data is not being recieved correctly. The LCD won't initialise properly.
 
Dear Gordz, I think you are right. I used simulator with same program but with 20 MHz frequency. LCD worked in simulator again..What does it mean? I think it means simulator is not sensitive for timing...Other side I made long initial silence period. But this lcd didnt work again. I want to try next step of my project. But it made me crazy as I coudnt pass this step. There is a print on my lcd circuit : ATM1602B is it an important detail?
 
That is merely a part number and is not importamts at the moment. When initialising an LCD module like this is is important to allow the time delays required for commands to complete. If you look at the code I posted there are delays at certain points in the initialisation sequence, perhaps this is where your problem lies. Try a VERY slow clock speed and if it works then this is your problem.
 
Last edited:
Dear Gordz I changed program according to your reccommends..No this ...hit circuit doesnt work..I attach my the newest version of my program. Please comment
 

Attachments

  • FADIK.txt
    3.1 KB · Views: 158
What you've done doesn't make any sense at all.

You need to put the delays between the calls to KOMUTYAZ, not within them.

Also, you haven't fixed the bug I pointed out two days ago. You need to do:

Code:
	MOVF	LCD_TEMP,0
	MOVWF	PORTB
	BSF	PORTD,E           ;this works
	BCF	PORTD,E

doing this:
Code:
	BSF	PORTD,E           ;this does not work
	MOVF	LCD_TEMP,0
	MOVWF	PORTB
	BCF	PORTD,E

Mike
 
Perhaps I shouldn't have been so adamant that setting the E flag must come after setting up the data. It is permissible to set the E flag early as long as the data is set long enough before the E flag is set back to zero. Setting the data before setting the E flag is just safer.

Mike
 
I looked at your code some more and it all looks okay. Since you are waiting for the LCD to not be busy (the call to MESGUL) the delays really shouldn't be necessary.

The init sequence appears to be okay. It sets:

8-bit mode, 2 display lines
Display on, cursor on
cursor moves in positive direction
clears the display
sets the cursor position to 0

The commands you are sending all look okay. Are you sure that the connections between the PIC and the LCD are all correct?

Were you able to adjust the contrast? In the picture you showed, the dark blocks on the first line indicate the need to adjust the contrast.

Mike
 
You haven't shown us what your CONFIG bits look like. Do you have the Watchdog Timer disabled? Are you sure that your PIC is running at all?

Mike
 
Your code does not work on the MPLAB simulator.

It never returns from the first call to Delay10ms. That is because of a bug in that code. There is one instruction out of place.

your code:

Code:
DELAY10ms
	BANKSEL	SAY10ms
	MOVLW	h'FF'
	MOVWF	SAY10ms
R10ms
	CALL	DELAY100us
	DECFSZ	SAY10ms
	MOVLW	h'FF'
	MOVWF	SAY10ms
KIZ
	DECFSZ	SAY10ms
	GOTO   	KIZ
[B]	GOTO   	R10ms                  this instruction out of place[/B]

	RETURN
it should be:
Code:
DELAY10ms
	BANKSEL	SAY10ms
	MOVLW	h'FF'
	MOVWF	SAY10ms
R10ms
	CALL	DELAY100us
	DECFSZ	SAY10ms
[B]	GOTO   	R10ms                  this instruction belongs here[/B]
	MOVLW	h'FF'
	MOVWF	SAY10ms
KIZ
	DECFSZ	SAY10ms
	GOTO	KIZ
	RETURN

Also, the corrected DELAY10ms routine actually delays about 25 ms.

When you added all those calls to DELAY10ms in KOMUTYAZ you lost the instruction that clears the E flag. You need to put that back in.

These last two bugs weren't in the original program that you posted here. You need to verify your code again. Remove the delays and fix these bugs and post it here again. I'll look at it.

Mike
 
Dear my brother Mike ,I made circuit two times. Then I thought maybe I make mistake and wanted a technician to make it for me. He made it two times also. I used different components in each tried circuit. It will make me crazy...
 
I'm sure there is just something simple wrong.

Attach the latest version of your code and I will go through it. Also, if you can do it, a photograph of the board and connections to the LCD would help. And post the CONFIG settings you are programming into the chip.

Mike
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top