I2C Slave with a PIC


Closed Thread
Results 1 to 40 of 130

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hey Kamikaze,

    I didn't see a problem from just looking at the code, so I ran it in the simulator.
    And I don't see a problem there either.

    On the master I get " 1 2 3 4 5 6".
    It does not change.

    I only added a toggle in the Master's main loop to verify it was looping.
    And a toggle in the Slave's handler, to verify the transfers.

    Is there something you stripped out before posting that could have caused it?

    Name:  SIM1.JPG
Views: 3902
Size:  108.4 KB
    DT

  2. #2
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    Thanks for looking DT. I'm currently running the above code "as is" on 2 breadboards side by side.

    Still losing a byte every time I do an i2cread.

    I tried reading one byte at a time instead of six, and I get: 1, 3, 5, 1, 3, 5. So no matter how many bytes I receive at once, it always skips the byte immediately proceeding those bytes.

    *edit* My circuit is identical to yours there DT except for 10mhz crystals + caps, and I only have an LCD on the master PIC.

    In case its relevant, these are my configs:

    Code:
            __CONFIG    _CONFIG1H, _OSC_HSPLL_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
            __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
            __CONFIG    _CONFIG3H, _CCP2MX_PORTC_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_ON_3H
            __CONFIG    _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L

    Quote Originally Posted by Darrel Taylor View Post
    Hey Kamikaze,

    I didn't see a problem from just looking at the code, so I ran it in the simulator.
    And I don't see a problem there either.

    On the master I get " 1 2 3 4 5 6".
    It does not change.

    I only added a toggle in the Master's main loop to verify it was looping.
    And a toggle in the Slave's handler, to verify the transfers.

    Is there something you stripped out before posting that could have caused it?

    Attachment 4704
    Last edited by Kamikaze47; - 16th August 2010 at 13:52. Reason: added more information
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Have you looked at the errata sheet for the silicon rev you have? This series has a lot of issues with the MSSP module & I2C.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  4. #4
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    I'll have a look at that errata sheet as you suggest.

    Incidentally, DT: What program do you use for PIC simulation? It looks like a handy tool to have.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kamikaze47 View Post
    Incidentally, DT: What program do you use for PIC simulation? It looks like a handy tool to have.
    It's Proteus VSM, and it's extremely handy.

    My breadboards are all covered in a layer of dust.
    They don't get used much anymore.
    DT

  6. #6
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    It's Proteus VSM, and it's extremely handy.

    My breadboards are all covered in a layer of dust.
    They don't get used much anymore.
    Unfortunately, as I feared, the price is pretty steep.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  7. #7
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    That was my initial reaction too.
    But I've since found that it is EXTREMELY inexpensive, if you consider the value vs. cost.

    You can't even buy a decent Digital O-Scope for that much.
    But Proteus gives you Multiple 4ch-DSO's, 32ch-logic analyzers, voltmeters, ammeters, virtual terminals, signal generators, pattern generators, power supplies, I2C debuggers, SPI debuggers, frequency counters ...

    There's a whole boat load of PIC's to choose from, plus all the other chips and discrete parts.
    You can simulate multiple PIC's in the same circuit simultaneously.

    And with PBP 2.60a, it integrates right into the MPLAB IDE for step by step debugging.

    $479 gives you all that and either the 16F's or 18F's.
    Can't get much cheaper than that.

    I should be getting a commission, I sound like a commercial.

    P.S. You can download the Demo Version and run your PBP programs on the sample circuits. You just can't modify the circuit.
        Take a test drive.
    <br>
    <br>
    Last edited by Darrel Taylor; - 17th August 2010 at 20:57. Reason: .
    DT

Similar Threads

  1. Problem with PICto PIC I2C MASTER-SLAVE
    By juanen19 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 11th June 2013, 02:58
  2. PIC as I2C Slave
    By Mainul in forum General
    Replies: 4
    Last Post: - 5th January 2013, 13:23
  3. I2C Slave, config Vref - + in pic with ADC
    By sebapostigo in forum PBP Wish List
    Replies: 4
    Last Post: - 5th March 2007, 03:21
  4. Pic as an i2c slave
    By Robert Soubie in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 25th January 2007, 21:11
  5. Use pic as slave in I2C
    By robert0 in forum General
    Replies: 2
    Last Post: - 3rd February 2006, 19:26

Members who have read this thread : 2

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