Making PSoC 3/5 functions reentrant | Cypress Semiconductor
Support & Community
Making PSoC 3/5 functions reentrant
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.