Is there anything like critical section within SDK?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Is there anything like critical section within SDK?

Jump to solution
734 Views
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

Labels (1)
Tags (2)
0 Kudos
1 Solution
529 Views
bobpaddock
Senior Contributor III

atomic.h attached gives the needed code.

    ATOMIC_BLOCK( ATOMIC_RESTORESTATE )

    {

      // protected stuff.

    }

View solution in original post

0 Kudos
2 Replies
530 Views
bobpaddock
Senior Contributor III

atomic.h attached gives the needed code.

    ATOMIC_BLOCK( ATOMIC_RESTORESTATE )

    {

      // protected stuff.

    }

0 Kudos
529 Views
tonymakkiel
Contributor III

Thank you very much :smileyhappy:.

0 Kudos