PSOC5: Hang in I2CM_MasterWriteBuf under FreeRTOS

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
ZvVe_2582751
Level 1
Level 1
5 replies posted Welcome! 5 questions asked

Hello,

Few months ago I created a discussion which I cannot locate.

I tried running I2CM_MasterWriteBuf after xSemaphoreTake.

The semaphore was created using xSemaphoreCreateCounting(1,1);

 

I used this semaphore because I had 2 tasks that use I2C so I needed a critical section mechanism.

In this scenario, I2CM_MasterWriteBuf hanged.

I think found a solution.

I used xSemaphoreCreateCounting, xSemaphoreTake  before running: vTaskStartScheduler();

When I created and used the semaphore in a task, I2CM_MasterWriteBuf worked fine.

Is this the the right solution ?

 

Thank you,

Zvika

0 Likes
1 Solution
BragadeeshV
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hi ZvVe_2582751​,

Welcome back to community.

SemaphoreCreateCounting can be called even before the TaskStartScheduler() is called or in a task. But xSemaphoreTake should be called only from the task and not anywhere else or before TaskStartScheduler()

Regards,

Bragadeesh

Regards,
Bragadeesh

View solution in original post

0 Likes
1 Reply
BragadeeshV
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hi ZvVe_2582751​,

Welcome back to community.

SemaphoreCreateCounting can be called even before the TaskStartScheduler() is called or in a task. But xSemaphoreTake should be called only from the task and not anywhere else or before TaskStartScheduler()

Regards,

Bragadeesh

Regards,
Bragadeesh
0 Likes