You have at least to declare that function as reentrant. Also take care that you are not accessing any global vars within that routine, if you do, you must disable interrupts during that acce4ss.
I did make the function as reentrant but this function calls some other function inturn ....should I make that aswell Reentrant???
And what happens if I were to use global variables because the functions I call are setting some status/flag kind bit....so if I am not supposed to use these variables how can i proceed
I missed the main part of the previous comment...... These functions can also be invoked by some of the critical interupts, i cannot let these interupt just go away or remain pending.... Please advice
Sit down and calm, it is not as complicated.
Try to imagine what may happen, when you call that function and while it is working an interrupt occurs and the function is called again. Since read-modify-write instructions are not atomic all of those may (will!) lead to something unpredictable. To help you to overcome these situations there are two helpers: The definition as "reentrant" which does not much in an ARM environment as a PSoC5 but is absolutely needed in a PSoC3 environment with its 8051....
Secondly there are the system-APIs CyEnterCriticalSection() and CyExitCriticalSection() which are intended for preventing small(!!!) areas of code beeing accessed simultaneously from different (or the same) pieces of code.
As some rules of thumb:
Local variables may be accessed without any restriction, they are allocated on the stach at function entry, or on a heap for reentrant 8051.
Local static vars should not be accessed in an interupt routine when the interrupt is re-enabled.
Global vars that must be accessed frim within an interrupt routine should
1. be declared as void
2. should be protected by critical sections when write accessed from outside the interrupt handler.
And to answer your last question: Yes, the functions you call from your interrupt-routine have to be declared as reentrant as well.
How to write Cyentercritical section and Cyexit critical section??
And what happens to the high priority interrupts ..will they be stopped when I am executing critical section or will they be pending.........If they will be pending then am i not sort of chsnging the priority?????
With the crucial info Bob has provided I think i need to redesign my program, .....Thnks for info Bob.....
Refer to Section 12 of the System Reference Guide which provides more details on CyEnterCriticalSection() & CyExitCriticalSection() APIs