i2C with PIC16F87, need help


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: i2C with PIC16F87, need help

    Here is an example of hardware I2C, wrong chip, but you should get the idea.
    http://www.picbasic.co.uk/forum/cont...-Master-Slaves
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: i2C with PIC16F87, need help

    Quote Originally Posted by mackrackit View Post
    Here is an example of hardware I2C, wrong chip, but you should get the idea.
    http://www.picbasic.co.uk/forum/cont...-Master-Slaves

    It might not be a good example for a 16F87.

    ...
    Like my other stuff, it ONLY works on 18F chips.
    ...
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: i2C with PIC16F87, need help

    Quote Originally Posted by Demon View Post
    It might not be a good example for a 16F87.
    No, it is not a plug and play, but the OP is wanting to know how to use the hardware and I figured it would get him started.

    He could use the software command as you pointed out butt there may be a reason why he can not.
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: i2C with PIC16F87, need help

    It definitely can't hurt to look that's fur sure.

    I don't know how many times I used bits and pieces from other designs and schematics when I was researching LCDs. They usually have particularities, but sometimes they share common techniques.

  5. #5
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: i2C with PIC16F87, need help

    The confusing thing about I2C is there are MASTER reads and writes, and SLAVE reads and writes.

    One of the definitions of an I2C MASTER is that the MASTER drives the clock.

    I2CWRITE and I2CREAD are both master-side commands. That is, an I2CWRITE will write data to a slave, and an I2CREAD reads data from a slave.


    So, you can't have communication between two PICs with I2CWRITE on one side and I2CREAD on the other. One side has to be the master and one side has to be the slave. Being a master is easy - you can start talking whenever you are ready. Being a slave is harder - you have to grab the data asynchronously, whenever it comes along. That is why it is best to have the slave be interrupt-driven as in my example.

    I don't know for certain that the code won't run on a 16F part. I never use them. But I do know that it works great on an 18F2221, 18F2321 and an 18F8723.
    Charles Linquist

  6. #6
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: i2C with PIC16F87, need help

    Quote Originally Posted by Charles Linquis View Post
    ...
    Being a master is easy - you can start talking whenever you are ready. Being a slave is harder - you have to grab the data asynchronously, whenever it comes along.
    ...

    And that would explain why I used USART to talk between Master-Slave PICs, and used I2C to talk to eeproms and I/O Expanders. lol

    That project dates back to 2005-2006, it's been a while.

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts