• AVR Freaks

Hot!I2C Harmony 2.06

Author
nich2011
New Member
  • Total Posts : 17
  • Reward points : 0
  • Joined: 2018/03/05 18:24:51
  • Location: 0
  • Status: offline
2020/02/07 01:31:55 (permalink)
0

I2C Harmony 2.06

Hi,
 
I2C port 1 = slave
I2C port 2 = master
I am trying to setup a slave I2C using PIC32MZ2048EFG144 with a few other ports acting as masters.
So, basically the slave would receive I2C transactions from an external master, process it and execute on port 2. Port 2 has its own state machine operation will be time consuming and I would like Port 1 slave to only transmit when port 2 master operation is completed. Any idea how make the slave callback function wait for process on port 2 to complete before transmitting through port 1?
 
void APP_I2C_Slave_Transfer_Callback(DRV_I2C_BUFFER_EVENT event, void * context)
{
    switch (event)
    {
        // master sends data to slave I2C1
        case DRV_I2C_BUFFER_SLAVE_READ_REQUESTED:
        {
            app_i2cData.i2c_id_1_buffer_handle = DRV_I2C_Receive(app_i2cData.i2c_id_1_driver_handle, SLAVE_I2C_ADDRESS, app_i2cData.i2c_id_1_RxBuffer, app_i2cData.i2c_id_1_BytesToRead, NULL);
            break;
        }
        
        // master requests data from slave I2C1
        case DRV_I2C_BUFFER_SLAVE_WRITE_REQUESTED:
        {
            app_i2cData.i2c_id_1_state = APP_I2C_ID_1_EXECUTE;
            while (!appData.is_process_complete)
            {
                
            }
 
 
 
            app_i2cData.i2c_id_1_buffer_handle = DRV_I2C_Transmit(app_i2cData.i2c_id_1_driver_handle, SLAVE_I2C_ADDRESS, app_i2cData.i2c_id_1_TxBuffer, app_i2cData.i2c_id_1_BytesToWrite, NULL);
            break;
        }
        
        default:
        {
            break;
        }
    }
}

post edited by nich2011 - 2020/02/16 19:54:43
#1

7 Replies Related Threads

    nich2011
    New Member
    • Total Posts : 17
    • Reward points : 0
    • Joined: 2018/03/05 18:24:51
    • Location: 0
    • Status: offline
    Re: I2C Harmony 2.06 2020/02/11 17:13:29 (permalink)
    0
    BUMP
    #2
    Paul PortSol
    Super Member
    • Total Posts : 583
    • Reward points : 0
    • Joined: 2015/07/03 11:52:03
    • Location: Newfoundland, Canada
    • Status: offline
    Re: I2C Harmony 2.06 2020/02/12 06:14:20 (permalink)
    0
    Haven't done PIC32MZ I2C as Slave,
    only warning I got is make sure you select "software implementation" for PIC32MZ I2C in MHC.
    Paul
    #3
    nich2011
    New Member
    • Total Posts : 17
    • Reward points : 0
    • Joined: 2018/03/05 18:24:51
    • Location: 0
    • Status: offline
    Re: I2C Harmony 2.06 2020/02/12 21:00:54 (permalink)
    0
    BUMP
    #4
    nich2011
    New Member
    • Total Posts : 17
    • Reward points : 0
    • Joined: 2018/03/05 18:24:51
    • Location: 0
    • Status: offline
    Re: I2C Harmony 2.06 2020/02/16 19:55:00 (permalink)
    0
    BUMP
    #5
    nich2011
    New Member
    • Total Posts : 17
    • Reward points : 0
    • Joined: 2018/03/05 18:24:51
    • Location: 0
    • Status: offline
    Re: I2C Harmony 2.06 2020/02/23 18:52:15 (permalink)
    0
    BUMP
    #6
    ric
    Super Member
    • Total Posts : 26159
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: I2C Harmony 2.06 2020/02/23 18:55:26 (permalink)
    0
    Plainly no users here know the answer.
    Time to ask Microchip themselves.
    You do that by raising a "Support Ticket" via http://microchip.com/support
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #7
    Mysil
    Super Member
    • Total Posts : 3667
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: online
    Re: I2C Harmony 2.06 2020/02/23 21:30:13 (permalink)
    0
    Hi,
    You may regulate priority between I2C Master, and I2C Slave code by selecting different  interrupt priority for
    interrupts from I2C peripherals handling Master and Slave connections.
     
    But when a interrupt have been triggered, and there are no higher priority interrupts beeing processed,
    then I cannot see a reason to try to keep back I2C slave processing. 
    better getting the callback and interrupt code completed as efficiently as possible.
     
    Be aware that any Callback function called from Interrupt Service code,
    will be running in that interrupt priority and context,
    so any trickery attempted in interrupt Callback code,
    will only slow down processing in any lower priority interrupt, and main loop code.
     
    Higher priority interrupt processing is not affected.
     
    Usually, neither Master nor Slave I2C processing is time critical.
    I2C master timing is entirely controlled by the master, and may be slowed down or delayed as needed.
     
    I2C Slave processing running in a microcontroller, depend on it's Master device respecting  Clock Stretching,
    for both address and data transfers.
    And also that Slave code release the clock signal when ready to proceed.
     
    Note, pay attention to what silicon hardware revision the PIC32MZ device is.
    Some silicon revisions have hardware Errata for the I2C peripherals.
    Read the Errata document for the device family beeing used.
     
        Mysil
    #8
    Jump to:
    © 2020 APG vNext Commercial Version 4.5