cancel
Showing results for 
Search instead for 
Did you mean: 

critical section example

togrady
Associate II
Posted on January 02, 2008 at 13:54

critical section example

2 REPLIES 2
togrady
Associate II
Posted on May 17, 2011 at 12:20

Hi,

I have implemented buffered uarts using interupts on the STM32. Can anyone provide a ''critical section'' example to disable interupts when getting data in or out of my circular buffers. I've used the code below in the past with other processors but I'm not sure how to implement the macros DISABLE_INTERRUPTS and ENABLE_INTERRUPTS on the STM32.

Code:

void EnterCriticalSection( void )

{

DISABLE_INTERRUPTS();

CriticalSectionNesting++;

}

void ExitCriticalSection( void )

{

if ((--CriticalSectionNesting) == 0)

ENABLE_INTERRUPTS();

}

Thanks

Trevor

sjo
Associate II
Posted on May 17, 2011 at 12:20

Your code looks like it was ripped from Freertos, why not just have a look at the cortexm3 port.

Cheers

sjo