• AVR Freaks

I2C Slave with Harmony 2.0.6.0 in StaticMode

Author
EH
Starting Member
  • Total Posts : 49
  • Reward points : 0
  • Joined: 2010/11/28 03:09:31
  • Location: 0
  • Status: offline
2019/07/05 03:59:22 (permalink)
0

I2C Slave with Harmony 2.0.6.0 in StaticMode

Hi Community,
 
I want to use two I2C modules. One as Master the other as Slave. I`m using the "DriverLibrary". The Master (index 0) is working without problems. For tests, I have two I2C modules as Slave (index1/index2).
 
For the Slave I have such SW:
 
void I2C_SlaveTasks(void)
{
    
    switch (i2cDataSlave.state)
    {
        case I2C_STATE_INIT:
        {
            ESP8266.drvI2CHandle = DRV_I2C_Open(DRV_I2C_INDEX_2, DRV_IO_INTENT_NONBLOCKING|DRV_IO_INTENT_READWRITE);
            if (DRV_HANDLE_INVALID == ESP8266.drvI2CHandle)
            {
// Handle open error
                Nop();
            }
// DRV_I2C_BufferEventHandlerSet( ESP8266.drvI2CHandle,
// APP_I2C_SlaveTransfer_Callback,
// ESP8266.TxBuffer);

            i2cDataSlave.state = SET_BUFFER;
            
            
            
          
            break;
        }
        case SET_BUFFER:
        {
            ESP8266.TxBuffer[0] = TempIstE.Val_H + 48;
            ESP8266.TxBuffer[1] = TempIstE.Val_T + 48;
            ESP8266.TxBuffer[2] = TempIstE.Val_O + 48;
            ESP8266.TxBuffer[3] = TempIstI.Val_H + 48;
            ESP8266.TxBuffer[4] = TempIstI.Val_T + 48;
            ESP8266.TxBuffer[5] = TempIstI.Val_O + 48;
            ESP8266.TxBuffer[6] = HumyIstI.Val_H + 48;
            ESP8266.TxBuffer[7] = HumyIstI.Val_T + 48;
            ESP8266.TxBuffer[8] = HumyIstI.Val_O + 48;

            ESP8266.BufferHandleTx = DRV_I2C_Transmit( ESP8266.drvI2CHandle,
                                                        ESP8266.address,
                                                        &ESP8266.TxBuffer[0],
                                                        ESP8266.TxNumBytes,
                                                        &ESP8266.TxBuffer[0]);
            i2cDataSlave.state = WAIT_FOR_MASTER;
            break;
        }
        case WAIT_FOR_MASTER:
        {
            ESP8266.BufferEvent = DRV_I2C_TransferStatusGet ( ESP8266.drvI2CHandle,
                            ESP8266.BufferHandleTx);
            
            if (ESP8266.BufferEvent == DRV_I2C_BUFFER_EVENT_COMPLETE)
            {
// ESP8266.TxBuffer[0] = TempIstE.Val_H + 48;
// ESP8266.TxBuffer[1] = TempIstE.Val_T + 48;
// ESP8266.TxBuffer[2] = TempIstE.Val_O + 48;
// ESP8266.TxBuffer[3] = TempIstI.Val_H + 48;
// ESP8266.TxBuffer[4] = TempIstI.Val_T + 48;
// ESP8266.TxBuffer[5] = TempIstI.Val_O + 48;
// ESP8266.TxBuffer[6] = HumyIstI.Val_H + 48;
// ESP8266.TxBuffer[7] = HumyIstI.Val_T + 48;
// ESP8266.TxBuffer[8] = HumyIstI.Val_O + 48;
                i2cDataSlave.state = SET_BUFFER;
            }
            break;
        }
    }
}

 
When I`m using the "DRV_I2C_BufferEventHandlerSet", then after the first sent package, all the Bytes get a "0xFF" and my program stops. When the MasterModule is inactive, all is working fine with the slave. When I have the solution above (without the "HandlerSet"), in the most cases the correct data was sent, but sometimes "0x00" packages. The other parts of my program is working. For the I2C Drivers, I´m using the "DynamicMode".
 
Then I decide to switch to the "StaticMode". I think, the different is, that all the I2C modules are using theyr own DriverFunktions. It is more divided, I guess. Here is the SlaveCallBackFunction required. But I could not get a working solution. The interrupt is enabled during the "DRV_I2C_Transmit" function, But the ISR is not started.
 
 
 
void __ISR(_I2C_5_VECTOR, ipl2AUTO) _IntHandlerDrvI2CInstance2(void)
{
    DRV_I2C2_Tasks(); <--Breakpoint set here, PC did not stop
 
}
 

 
 
For the MasterModule, the ISR is called.
 
So far I could see, all the interrupt-stuff was configured by Harmony during the SystemInit, I guess.
 
It would be nice, when I could get some suggestions/hints where could be the problem.
 
Thank you
Henry
 
 
 
 
 
#1

0 Replies Related Threads

    Jump to:
    © 2019 APG vNext Commercial Version 4.5