This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Interfacing code for 89C51 to PCF 8574 to interface LCD in 4bit

hey,
can some1 help me to interface PCF 8574 with 89c51 using I2C bus for interfacing LCD in four but mode please..
its for my final year project it will help me alot if
any1 can help me out for the code..
coz im not able 2 get it done.. i dont understand
it actually..

Parents
  • Best descriptions of how I2C works can be found from NXP - they (under their old name) are the inventor of the protocol.

    There is no datasheet? Are you saying that your tutor has not given you any datasheet, or are you saying that you have googled for a datasheet for your specific display but failed to find anything?

    Note also that a huge number of displays are designed based on quite few controller chips, so it should be possible to find other displays that uses the same chip and that have excellent datasheets describing timing, commands, ...

    You can separate your project into several parts.

    One part is to play directly with the display, and get it to communicate. That is possible if your processor have enough pins for you to interface them directly. Just make sure that the signal levels of the display and the processor are the same, so you don't interface a 3.3V device with a 5V device.

    Another project is to learn how to use the I2C bus expander. Don't connect any LCD to it. Just experiment by sending I2C commands to it and let the outputs control LEDs. The datasheet for the bus expander will tell what to send to control the outputs.

    Then merge display and bus controller and use I2C commands to set the I/O signals to the states your previous module sent directly to the display. If you are careful then everything may work directly. If not, then it is probably caused by the changed timing caused by the I2C transfer. However, the display datasheet (which is possible to find - or at least a comparable datasheet) should tell the required timing, so an oscilloscope should be able to show any timing errors.

    Don't see problems, do see challenges. When the challenge is too large: Figure out how to split it into smaller challenges and work on them one-by-one.

    The final projects really are expected to require you to gather new knowledge on your own. This in comparison to some of the smaller laboratory exercises that are just there to let you directly practice what you have just learned. In real life, you will not be asked to do exactly what you have already been teached to do. As the time passes, the requirements will change more and more and the knowledge you picked up at school will grow old. In the end, you can't be productive unless you are ready to all the time look for new knowledge.

    And I really mean look for new knowledge. Not just ask for the knowledge. The rest of the world do not have the time to feed you knowledge. Only you have that time. And when you get out in the commercial world, only you will get money for doing your work. Other people will not see any real incentive to spend time doing your work.

Reply
  • Best descriptions of how I2C works can be found from NXP - they (under their old name) are the inventor of the protocol.

    There is no datasheet? Are you saying that your tutor has not given you any datasheet, or are you saying that you have googled for a datasheet for your specific display but failed to find anything?

    Note also that a huge number of displays are designed based on quite few controller chips, so it should be possible to find other displays that uses the same chip and that have excellent datasheets describing timing, commands, ...

    You can separate your project into several parts.

    One part is to play directly with the display, and get it to communicate. That is possible if your processor have enough pins for you to interface them directly. Just make sure that the signal levels of the display and the processor are the same, so you don't interface a 3.3V device with a 5V device.

    Another project is to learn how to use the I2C bus expander. Don't connect any LCD to it. Just experiment by sending I2C commands to it and let the outputs control LEDs. The datasheet for the bus expander will tell what to send to control the outputs.

    Then merge display and bus controller and use I2C commands to set the I/O signals to the states your previous module sent directly to the display. If you are careful then everything may work directly. If not, then it is probably caused by the changed timing caused by the I2C transfer. However, the display datasheet (which is possible to find - or at least a comparable datasheet) should tell the required timing, so an oscilloscope should be able to show any timing errors.

    Don't see problems, do see challenges. When the challenge is too large: Figure out how to split it into smaller challenges and work on them one-by-one.

    The final projects really are expected to require you to gather new knowledge on your own. This in comparison to some of the smaller laboratory exercises that are just there to let you directly practice what you have just learned. In real life, you will not be asked to do exactly what you have already been teached to do. As the time passes, the requirements will change more and more and the knowledge you picked up at school will grow old. In the end, you can't be productive unless you are ready to all the time look for new knowledge.

    And I really mean look for new knowledge. Not just ask for the knowledge. The rest of the world do not have the time to feed you knowledge. Only you have that time. And when you get out in the commercial world, only you will get money for doing your work. Other people will not see any real incentive to spend time doing your work.

Children
  • Sir im using I2C expander pcf 8574
    so im connecting it to the sda and scl
    line to my uC.
    then im confused abt should i send
    the data during the sda line is high right???
    in the routine i messaged in my earlier post??
    tats the problem im not able 2 get..
    my tutor is of no help he just wants to see
    the progress in my work..
    Everything has 2 be done by us he will just
    see weekly updates tat how we are doing n all
    tats abt it..

  • "the data during the sda line is high right???"

    Obviously, to send data you have to select if the sda line is high or low. If you always keep sda high, you will obviously only send high data.

    It is the clock line that represents time, so you have to think about the state of the clock signal when you send your data.

    But the above should be absolutely clear if you did search for the excellent descriptions of I2C that are available on the NXP web site. Your confusion only indicates that you have not spent time reading up on I2C. Your tutor wants weakly progress reports. But that indicates that weeks are passing by. Think about how much time you have to read about I2C in one week...

    You see, we can't help you with the I2C unless you read yourself. Whatever we write here will not be able to match the documentation NXP already have available. They have spent weeks or months on writing high-quality documentation, so if we spend hours trying to describe (summarize) the I2C functionality, we would end up with a way worse description. And without all the nice illustrations showing the timing relationship between the data and the clock signals, and describing the different states that makes it possible to not just send data to the chip (as in a shift register with clock + data) but how you synchronizes with the chip (as in getting the two lines to also represent a reset/clear signal).

    You have to realize something: Your tutor might actually be very helpful. But only if you can focus enough to ask him/her specific questions about problems that you have pinpointed and where you can show that you have really cornedred the problem - spent enough time hunting for solutions on your own but found multiple possible interpretations where you fail to figure out which interpretation that is correct.

    Your tutor is not interested in you asking wild-card questions: How do I get I2C to work? Why? Because that quastion was one of the main tasks for you to find out about yourself. Answering that question would be the same as handing over an already working solution to you and then ask you to directly hand it back in as your work. Aswering the wild-card questions you are asking on this forum would be the same as letting you skip your assignment. Letting students skip their assignments would be cause for firing the tutor.

  • "But the above should be absolutely clear if you did search for the excellent descriptions of I2C that are available on the NXP web site"

    Not least of which is the PCF8574 Datasheet itself!

    This provides a very clear description of how to drive the I2C interface to this device - complete with timing diagrams to illustrate it.

    In fact, this is probably one of the best documents to start with for an introduction to I2C - without all the complications of the full specification (which is available for free download from the NXP site)

    The PCF8574 is a very well-established, popular device - there must be plenty of examples available for you to look at!