Showing results for 
Search instead for 
Did you mean: 

Knowledge Base Articles

Making PSoC 3/5 functions reentrant


Making PSoC 3/5 functions reentrant

Question: How to make PSoC 3/5 functions reentrant?



Functions (including Component APIs) written using the C51 compiler are typically NOT reentrant. The reason for this limitation is that function arguments and local variables are stored in fixed memory locations due to limited size of the 8051 stack. Recursive calls to the function use the same memory locations. And, in this case, arguments and locals would get corrupted.




Reentrant functions can be called recursively, and can be called simultaneously by two or more processes. Reentrant functions are often required in real-time applications or in situations where interrupt code, and non-interrupt code must share a function. The "reentrant" function attribute in KEIL compiler allows you to declare reentrant functions. Refer to the application note “AN54460: Interrupt Handling in PSoC 3“ for knowing how to declare and define a reentrant function.

Version history
Revision #:
1 of 1
Last update:
‎Mar 14, 2011 02:34 PM
Updated by: