- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
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,
Zvika
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Zvi,
Which device and IDE are you using?
Regards,
Bragadeesh
Bragadeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Trung,
Can you refer to the code example CE223468 – PSoC 6 MCU: Interfacing BMI160 (I2C) in FreeRTOS?
Regards,
Bragadeesh
Bragadeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bragadeesh,
I'm using Creator 4.0, PSOC 5 (CY8C5868AXI-LP035)
Thank you,
Zvika
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Zvika,
Can you please check if any other task is using the I2C bus line? Because the MasterWriteBuf returning 2 means "the master is not a valid master on the bus, or a slave operation is in progress". I'm suspecting that some other task has not given up the I2C resource? Was the previous code example I shared of any use?
Regards,
Bragadeesh
Bragadeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bragadeesh,
Thank you for your help !
I got rc=2 before any task was launched and before calling to xSemaphoreTake.
In the init phase of the application I called xSemaphoreCreateCounting.
If the semaphore is not created, rc=0.
No one is using the semaphore at this stage.
Best regards,
Zvika
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Can you please share your project file here so that I will try to find out the issue?
Regards,
Bragadeesh
Bragadeesh