I2C Slave with a PIC


Closed Thread
Results 1 to 40 of 130

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Please help me understand how the application works

    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  2. #2
    Join Date
    Jun 2011
    Location
    Philippines
    Posts
    223


    Did you find this post helpful? Yes | No

    Default Re: Please help me understand how the application works

    Thanks mister_e

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


    Did you find this post helpful? Yes | No

    Default Re: Please help me understand how the application works

    Or you can stuff it in a ZIP file and post it here. The forum accepts ZIPs as attachments.

    Some RAR programs can also save as ZIP format.

    Robert

  4. #4
    Join Date
    Jun 2011
    Location
    Philippines
    Posts
    223


    Did you find this post helpful? Yes | No

    Default Re: Please help me understand how the application works

    Thanks for the info Robert...
    and here is the zip file.

    Regards,
    tacbanon
    Attached Files Attached Files
    Last edited by tacbanon; - 28th April 2012 at 06:03.

  5. #5
    Join Date
    Jun 2011
    Location
    Philippines
    Posts
    223


    Did you find this post helpful? Yes | No

    Default Re: Please help me understand how the application works

    Oops here are the codes I'm using for the master, Slave1 and Slave 2.
    Attached Files Attached Files

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


    Did you find this post helpful? Yes | No

    Default Re: Please help me understand how the application works

    Thanks for the files tacbanon.

    Well, this code for the slaves will allow it to read from both devices.
    Code:
    main:  
        IF SSPCON1.6 THEN SSPCON1.6 = 0
    goto main 
    
    i2c_int_handler:
        IF i2c_read then
            IF i2c_buffer_full=0 THEN
                SSPBUF=i2c_data[i2c_data_index]
                i2c_data_index=i2c_data_index+1
            ELSE
                dummy = SSPBUF
            ENDIF
        ELSE
            i2c_data_index=0
        ENDIF
        i2c_release_scl=1 
    @ INT_RETURN
    But it's still not right. And is not a complete slave.

    According to AN734 there are 5 states to maintain. 6 including the ERROR state.
    Your original code only handles 1 state, and this modification only does 2 states.

    I think by adding the other 4 states, it will get rid of the buffer overflows, but I'm not absolutely sure.
    I'm going to convert AN734 state machine to PBP and see what happens.
    May take me awhile.
    Last edited by Darrel Taylor; - 28th April 2012 at 18:17.
    DT

  7. #7
    Join Date
    Jun 2011
    Location
    Philippines
    Posts
    223


    Did you find this post helpful? Yes | No

    Default Re: Please help me understand how the application works

    Thank you for the code, and thanks in advance DT for your valuable time...looking forward for the end result(I wish and pray that things goes well). I've been reading about I2C on net, trying to understand and the applications that might be done(particularly on Master-(multi-Slave/Multi-master)) are very interesting...

    Regards,
    tacbanon
    Last edited by tacbanon; - 29th April 2012 at 03:26.

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, 03:58
  2. PIC as I2C Slave
    By Mainul in forum General
    Replies: 4
    Last Post: - 5th January 2013, 14:23
  3. I2C Slave, config Vref - + in pic with ADC
    By sebapostigo in forum PBP Wish List
    Replies: 4
    Last Post: - 5th March 2007, 04:21
  4. Pic as an i2c slave
    By Robert Soubie in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 25th January 2007, 22:11
  5. Use pic as slave in I2C
    By robert0 in forum General
    Replies: 2
    Last Post: - 3rd February 2006, 20:26

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