I2C Slave with a PIC


Results 1 to 40 of 130

Threaded View

  1. #19
    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 17:17.
    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