Yes, you can call a function within the ISR but it is not recommended because it can increase the interrupt latency and decrease the performance of the system. If you want to call a nested function within the ISR, you need to read the datasheet of your microcontroller because some vendors have a limit to how many calls can be nested.
One important point needs to remember that the function that is called from the ISR should be re-entrant. If the called function is not re-entrant, it could create the issues.
For example, If the function is not reentrant and supposes that it is called by another part of the code beside the ISR. So the problem will be invoked when if the ISR calls the same function which is already invoked outside of the ISR?
Answer:
Yes, you can call a function within the ISR but it is not recommended because it can increase the interrupt latency and decrease the performance of the system. If you want to call a nested function within the ISR, you need to read the datasheet of your microcontroller because some vendors have a limit to how many calls can be nested.
One important point needs to remember that the function that is called from the ISR should be re-entrant. If the called function is not re-entrant, it could create the issues.
For example,
need an explanation for this answer? contact us directly to get an explanation for this answerIf the function is not reentrant and supposes that it is called by another part of the code beside the ISR. So the problem will be invoked when if the ISR calls the same function which is already invoked outside of the ISR?