Its because my ISR has a flag=1 so when the ISR finish, with the flag a function will enter in the play and run a series of sub programs, thats why I wanted to block the UART ISR while the PIR is active, because as soon the PIR detects something, it will run a different set of sub programs, and in the meantime, the other way shouldnt work, I know that maybe is the best way but its all I got bymyself haha. With some knowledge and time it can improve
No...that's a bad idea. That defeats the purpose of the interrupt by turning it off until the PIR routine is done. Mainly because the PIR routine sounds like it is going to take a while to run and because there does not seem to be a good reason (as far as we can tell, you haven't told us) why the PIR code must not be interrupted.
There are few reasons why you would need to stop the UART ISR from running in the middle of the PIR code (in the main loop) is running. The main one is if the code and ISR somehow interact with each other (such as using a shared resource) that would interfere with proper operation.
For example: If the UART ISR needs to transfer a continuous sequence of characters into some memory but the PIR code also transfers characters into that same memory block and you don't want a PIR data block to end up in the middle of a UART characters sequence.
The only other good, general reason I can think of that when the PIR is triggered, the MCU enters another mode of operation permanently or semi-permanently where the UART is no longer relevant.
Answer this: If a UART interrupt tries to fire while the PIR code is running, do you want the UART ISR to run right after the PIR code is finished? If so, disabling the UART ISR is a
sub-optimal and unnecessary unless the two pieces of code interfere with each other somehow (like they both used a shared resource as previously described).
Divide the PIR algorithm into two parts:
1. the stuff that must be taken cared of right away.
2. the stuff that can wait.
Divide the UART algorithm into the same two parts.
Stick the stuff that must be done right away into interrupts and put everything else into the main loop of the program. Set the flags in the ISR and read the flags in the the main loop of the program knows what's going on.