Calling component APIs from ISR | Cypress Semiconductor
Support & Community
Calling component APIs from ISR
What is the recommended method for calling component APIs from interrupt service routines in PSoC 3?
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.
Hence, the same component APIs should not be called in multiple threads like background loops and ISRs.
When it is absolutely required to call the component APIs in multiple threads, then disable the global interrupt while executing the component APIs in lower priority threads. Note that disabling interrupt would increase the latency of higher priority thread.
The Macro for disabling and enabling global interrupt is given below:
For more details on Re entrancy, Please refer to the Application Note on Interrupt Handling in PSoC3 (AN54460).
Also please refer to the Application Note on Optimizing 8051 Code in PSoC3 (AN60630)