I have read in this website: http://www.engineersgarage.com/embedded/avr-microcontroller-projects/interface-lcd-4bit-mode-circuit that when I need to send a command in 4 bits I have first to send a function set command which states 4 bits mode 2 lines and 5x7 font which is 0x28 but we cant send this using 4 bits mode because the lower nibble wont be read so instead I think we should use 0x20 then 0x80 but this website says that I need to make 0x02 while that time the 2 will be in the lower nibble which wont be sent so how can that happen? I have been wondering for so long on how can this happen and I would very much appreciate anyone who can spend a bit of his time to explain this to me and I would be very thankful.
Asked
Active
Viewed 159 times
-2
-
2Are your comma, dot and Enter keys broken? The question is a wall of illegible text... – The Paramagnetic Croissant Aug 23 '14 at 18:29
-
sorry @TheParamagneticCroissant what did I do wrong? – user3674628 Aug 23 '14 at 18:31
-
@userXXX You haven't separated phrases and clauses into different sentences and paragraphs. You should format your question nicely so that it's easy to read. – The Paramagnetic Croissant Aug 23 '14 at 18:35
-
do u know the answer of my question @TheParamagneticCroissant? – user3674628 Aug 23 '14 at 18:36
-
I don't really know what u mean by format it nicely it just cant be formatted I have no steps to number or code to add and it is a small part for anyone to read if u have any ideas what do I need to do to format it I would be very happy to hear it... – user3674628 Aug 23 '14 at 18:38
-
Paramagnetic isn't looking for lists, but sentences. There are a few questions about this on [ee.se], but the few I looked at didn't really describe it if you don't know where to start. Here is a complete datasheet of the [driver your chip emulates](https://www.sparkfun.com/datasheets/LCD/HD44780.pdf). See page 46 for 4-bit initialization. Basically, you pretend you are sending 8 bits for the first command and the low 4 bits are random, but the high 4 bits say to enter 4 bit mode. Then you can send another initialization command from 4 bit mode to set the other bits. – ughoavgfhw Aug 23 '14 at 18:44
-
I actually know where to start @ughoavgfhw but I need to know why did he put a 0x02 which will not be read because there is a 0 on the higher nibble and the lower nibble is not read instead of 0x20 which is the right one because the 2 is the one which is gonna be read and there is 0 on the lower nibble??? – user3674628 Aug 23 '14 at 19:05
-
Oh, I see. Answer in a bit. – ughoavgfhw Aug 23 '14 at 19:30
1 Answers
0
If you look at the code for dis_cmd
, you will see that it first sends the high nibble, then the low nibble. There is no way to make it send only one. Let's look at the two possibilities:
dis_cmd(0x20)
: Writes 0x2 then 0x0
dis_cmd(0x02)
: Writes 0x0 then 0x2
As you can see, there will always be an extra 0 sent. If the value 0x20 were used, this would be sent after the mode was changed, causing it to be interpreted as the high nibble of a command, which makes any future command wrong. By sending 0x2, the extra 0 is sent first. It is interpreted as an 8 bit command with the high nibble clear, followed by a command to enter 4 bit mode. Sending a random command on startup is not ideal, but it does work without corrupting future commands.

ughoavgfhw
- 39,734
- 6
- 101
- 123
-
thanks thanks thanks very much ughoavgfhw this was the question that confused me for a long while u helped me alot – user3674628 Aug 23 '14 at 20:18