cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC™ 6

Anonymous
Not applicable

Hi,

I am still learning about the Cortex architecture after many years using 8 bitters; apologies if this is too simple....

Is there a way to store the global interrupt enable status prior to entering a critical code section?

For example, in AVR, you can preserve the global interrupt state with, instead of a naive cli(); sei();

uint8_t sreg = SREG; //preseve global mask state

cli(); //disable global interrupts

//do something critical

SREG = sreg; //restore global state

How is this done w/ PSOC 6?

Thanks in advance...

Scott

0 Likes
1 Solution
MeenakshiR_71
Employee

Hello Scott,

In PSoC 6 this is accomplished using Cy_SysLib_EnterCriticalSection and Cy_SysLib_ExitCriticalSection APIs. The flow is below -

/* Preserve global mask state and enter critical section */

uint32_t interruptState = Cy_SysLib_EnterCriticalSection();

/* do something critical */

/* Restore global state */

Cy_SysLib_ExitCriticalSection(interruptState);

Let me know if this helps.

Regards,

Meenakshi Sundaram R

View solution in original post

0 Likes
2 Replies
MeenakshiR_71
Employee

Hello Scott,

In PSoC 6 this is accomplished using Cy_SysLib_EnterCriticalSection and Cy_SysLib_ExitCriticalSection APIs. The flow is below -

/* Preserve global mask state and enter critical section */

uint32_t interruptState = Cy_SysLib_EnterCriticalSection();

/* do something critical */

/* Restore global state */

Cy_SysLib_ExitCriticalSection(interruptState);

Let me know if this helps.

Regards,

Meenakshi Sundaram R

View solution in original post

0 Likes
Anonymous
Not applicable

Thank you!

0 Likes
Top labels