6 Replies Latest reply on Nov 29, 2018 11:18 PM by BragadeeshV_41

    I2C Master/Multi-Master/Slave with FreeRTOS




      I developed an application that uses the following calls of:

      uint8 I2C_MasterWriteBuf(uint8 slaveAddr, uint8 * wrData, uint8 cnt, uint8 mode)

      uint8 I2C_MasterReadBuf(uint8 slaveAddr, uint8 * rdData, uint8 cnt, uint8 mode)


      In order to read data from FRAM.

      It works fine.


      Then I integrated FreeRTOS inside  this application.

      The IIC is a resource that should be used in few tasks.

      So I create a counting semaphore in order to implement a critical section:


      xSemaphoreTake (..)

      I2C_MasterWriteBuf (..)

      xSemaphoreGive (..)


      The problem:

      I created the semaphore with:

      SemaphoreHandle_t  sem = xSemaphoreCreateCounting(1, 1);


      After the semaphore creation, I2C_MasterWriteBuf started to return 2 and not 0.

      I did not call to xSemaphoreTake and xSemaphoreGive  yet.


      What can cause it ?


      Thank you,