??? 07/15/06 21:41 Read: times |
#120300 - A few possible problems Responding to: ???'s previous message |
;--------------------4bit write sequence--------------------- write_4bit: push 00h ;mov r0,a rlc a mov p0.0, c rlc a mov p0.1, c rlc a mov p0.2, c rlc a mov p0.3, c ;mov a,r0 pop 00h ret What is this subroutine supposed to do? There are no comments and why does it push/pop 00h? My interpretation of this code is that it copies A.7 -> P0.0 A.6 -> P0.1 A.5 -> P0.2 A.4 -> P0.3 Is this what it is supposed to do? The is reverse to what I would expect. Another way of doing the same thing is: ; ; ; copy lower 4bit nibble in A to the lcd data pins ; ; write_nibble: mov c,A.0 mov LCD_D0,c mov c,A.1 mov LCD_D1,c mov c,A.2 mov LCD_D2,c mov c,A.3 mov LCD_D3,c ret The comment above the subroutine tells you all you need to know. Using meaningful names for the port pins helps to document the code. You have omitted critical information in your code that allows another person to understand and/or check it. What port pins do what? What are the subroutines supposed to do? I'm sorry to be so critical of your code, but the secret to writing defect free code is to document it so you can remember what you wrote and so that other people can understand also. At the moment we all have to assume many things in order to make sense of your code - these assumptions may be wrong. Some hints as to what may be the problem: 1. Read the datasheet for the lcd controller - you do not follow the initialisation sequence for 4 bit mode. This is critical. 2. What speed/type of cpu are you using. Timing is critical with the lcds. Anything over 12MHz/12clock will require extra delays in the setb EN,clr EN sequence. Again, read the datasheet. 3. Use a simulator to ensure that what you think your code is doing actually happens. This will save you a lot of time. 4. Use pullup resistors if using port0. 5. Write code with comments |
Topic | Author | Date |
lcd code not working in bit mode. | 01/01/70 00:00 | |
correction=>the code here is for 4bit mode | 01/01/70 00:00 | |
A few possible problems | 01/01/70 00:00 | |
a few blind shots | 01/01/70 00:00 | |
Whats wrong with | 01/01/70 00:00 | |
the difference is... | 01/01/70 00:00 | |
You can do | 01/01/70 00:00 | |
So mask it | 01/01/70 00:00 | |
Yes I realise this! | 01/01/70 00:00 | |
I didn't know that... | 01/01/70 00:00 | |
A.x | 01/01/70 00:00 | |
8bit mode works by entering 38h only once | 01/01/70 00:00 | |
But you're not using 8 bit mode. | 01/01/70 00:00 | |
LCD datasheets ... | 01/01/70 00:00 | |
A contentious issue! | 01/01/70 00:00 | |
cpu and speed | 01/01/70 00:00 | |
Oakely Doakely | 01/01/70 00:00 | |
Clear LCD delay too short? | 01/01/70 00:00 | |
Check this also | 01/01/70 00:00 | |
delays are just fine | 01/01/70 00:00 | |
Did you try... | 01/01/70 00:00 | |
Look here | 01/01/70 00:00 | |
also note that... | 01/01/70 00:00 | |
thank you Jon![]() | 01/01/70 00:00 | |
You Sure | 01/01/70 00:00 |