??? 02/03/07 16:00 Read: times |
#131952 - normal? Responding to: ???'s previous message |
Are you sure the contrast is fading?
When an LCD is first on, you should see the first line (or 1/2 a line if it is a 1-line display) as a set of black squares. In a 16-character 2-line display, you should see 16 black squares in the first row, and 16 faint squares in the second row. Adjust the potentiometer until the faint squares appear. Someone earlier thought you didn't attempt to initialize the LCD. Your code makes me think that (s)he is wrong. I agree with another poster that timing is a huge issue with LCD's. According to several datasheets, it takes from 37us to 1.64ms for a command to be processed. First, determine what the speed of the oscillator (or crystal) you are using with the microcontroller. If it is a crystal, the packaging that came with it will indicate it. Next, use the datasheet for your microcontroller to determine how many clock cycles it takes to process one instruction. In most cases, the answer is 12. Now, take your crystal frequency, and divide that by the number you got from the datasheet. now divide 1 by your result (not result divided by one). this will indicate how long it takes for the microprocessor to process most single instructions. You may need to look at a datasheet that shows you how many clock cycles it takes for each instruction to execute. Many take one, some take 2, and a few take 4. Now write your code so that at least 2ms passes before an LCD is written to. The easiest way to do this is to create a delay. Here's some code. Please note that I am not making this code for any specific assembler. All values are in hex. mov R2,FF loop2 mov R3,FF loop1 djnz R3,loop1 djnz R2,loop2 Basically, this code counts from 0 to about (255 * 255), where the delay between each count is about (crystal frequency/(cycles per instruction)). so there is nothing wrong with your LCD. If it was actually fading and you were using batteries, replace them. |