Is there anything like critical section within SDK?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Is there anything like critical section within SDK?

跳至解决方案
961 次查看
tonymakkiel
Contributor III


Hi,

        Is there something like windows critical section within SDK 2.0 (or a mutex/semaphore will do). I am not using any RTOS. Basically there is a function which I do not want the system to interrupt, to service anything else. I am using SDK 2.0 for KL43.

 

The problem is the function shares a variable with uart callback function. So if there is a uart callback while the function is being services, the call back function changes the value and if my function is half way through processing based on initial value, when it resumes it goes crazy!

 

Many Thanks,

Tony

标签 (1)
标记 (2)
0 项奖励
回复
1 解答
756 次查看
bobpaddock
Senior Contributor III

atomic.h attached gives the needed code.

    ATOMIC_BLOCK( ATOMIC_RESTORESTATE )

    {

      // protected stuff.

    }

在原帖中查看解决方案

0 项奖励
回复
2 回复数
757 次查看
bobpaddock
Senior Contributor III

atomic.h attached gives the needed code.

    ATOMIC_BLOCK( ATOMIC_RESTORESTATE )

    {

      // protected stuff.

    }

0 项奖励
回复
756 次查看
tonymakkiel
Contributor III

Thank you very much :smileyhappy:.

0 项奖励
回复