This would be a safe assumption. It's all manual If you disable interrupts when beginning, you must re-enable it if you want to use it again.If in some function I declare them momentary disabled (GIE=0 . PEIE=0 . ETC) Will be the ISR disabled until I re enable the registries again ?
void interrupt ISR()
{
if(RCIF)
{
// do usart stuff..
RC1IF = 0;
}
if (RBIF)
{
// do port change stuff..
// to clear RBIF you need to read the port!
}
if(INT0IF)
{
// do external int stuff..
INT0IF = 0;
}
}
So with this, are you suggesting to use only one ISR for those task ? I never thought it would be possible, in that case I would have to disable the UART section or something similar, because I dont want them to clash before it finish if a function was called with the external interrupt task.A frame work...
C:void interrupt ISR() { if(RCIF) { // do usart stuff.. RC1IF = 0; } if (RBIF) { // do port change stuff.. // to clear RBIF you need to read the port! } if(INT0IF) { // do external int stuff.. INT0IF = 0; } }
Sometimes, multiple interrupst share the same trigger (to conserve circuitry inside the chip) so multiple interrupts (often related somehow like different types of interrupts for the same peripheral) share the same hardware trigger and routine so whenever that trigger fires, the routine must check flags to see which specific interrupt fired in order to run the appropriate code. Remember to clear that pending flag at the end of the routine or else your interrupt will instantly trigger again.So with this, are you suggesting to use only one ISR for those task ? I never thought it would be possible, in that case I would have to disable the UART section or something similar, because I dont want them to clash before it finish if a function was called with the external interrupt task.
So with this, are you suggesting to use only one ISR for those task ?
Okay let me go a little more in depth, Im at my office right now, so I dont have access to my MCU'S, so I will try my best.Yes, that's how it's done, on most devices - the high/low priority isn't much different, it just decides which one gets processed first. The 24F series have a range of settings with different priorities, and each interrupt calls a separate ISR, I find that more confusing than anything else and pretty well choose the priorities at random.
You don't need to disable things, the processor takes care of what needs doing, only one interrupt at a time runs, any others are queued and run when the current one finishes.
The important thing is to keep ISR's as short and fast as possible, but that applies to interrupts in general.
Even using assembler, many more modern PIC's automatically save (and restore) the registers when ISR's are called, which saves you having to do it.
I will take a look on these, but 1st , I with the help of everyone here, I will determine if its necesary to do the upgrade, I have a feeling that what im trying to do is not complex enough to need more features, in case if needed I would have to get it then.In single vector mode you just chain the interrupt flags checks down in a series of checks in one ISR function. It's usually a good idea to also check the enable flag for each ISR checked module first so you can easily disable interrupt servicing individually if some flags are being polled elsewhere.
There are PIC18 devices with multi-vector (more than high/low) interrupts.
https://ww1.microchip.com/downloads/en/AppNotes/90003162A.pdf
You dont have to do anything if not nesting interrupts since one interrupt must finish before another one can run.Okay let me go a little more in depth, Im at my office right now, so I dont have access to my MCU'S, so I will try my best.
Im sitting in a while(1); when UART is used it activates a flag and start running some sub programs. When it finish, it goes back to sit in the while(1); until being called again. But now, I would like to add a new feature, an external interrupt using an external source, lets say a PIR SENSOR like an example. If the sensor spot something, it will do something, BUT. I wouldnt like that UART interrupt activate during the external ISR process, Im not sure if im being clear, if not, I can try to explain again. So in conclusion, Would be necesary to block the UART flags or something while the PIR is working? and also the opposite, block the PIR while the UART is being executed. Im clear that ISR must be short and fast as possible.
Okay let me go a little more in depth, Im at my office right now, so I dont have access to my MCU'S, so I will try my best.
Im sitting in a while(1); when UART is used it activates a flag and start running some sub programs. When it finish, it goes back to sit in the while(1); until being called again. But now, I would like to add a new feature, an external interrupt using an external source, lets say a PIR SENSOR like an example. If the sensor spot something, it will do something, BUT. I wouldnt like that UART interrupt activate during the external ISR process, Im not sure if im being clear, if not, I can try to explain again. So in conclusion, Would be necesary to block the UART flags or something while the PIR is working? and also the opposite, block the PIR while the UART is being executed. Im clear that ISR must be short and fast as possible.
Oh i get it, i guess, I could use an "if(PIR)" inside of the while(1)? where the PIR can be something like "#DEFINE PIR RB0" since my ISR is being used by an USART code, I would like then to disable momentaly the USART ISR while im proccessing the PIR program, so when the PIR finishes and goes out of the if(PIR) the flag of the USART wouldnt be activated if for some reason it was called during the other process.No, use short ISR's that set flags, then check for the flags in the main program within the while{1} - it would only very rarely be useful to turn off other interrupts - the only time I do is for UART routines, where I'm expecting just a single string to be received, so I disable UART interrupts while I'm processing the current one - just in case.
However, a PIR is a VERY slow and low priority device, and hardly worth an interrupt, just polling in the while{1} should be plenty - pretty much the same as using an interrupt to set a flag, and then polling the flag.
Oh i get it, i guess, I could use an "if(PIR)" inside of the while(1)? where the PIR can be something like "#DEFINE PIR RB0" since my ISR is being used by an USART code, I would like then to disable momentaly the USART ISR while im proccessing the PIR program, so when the PIR finishes and goes out of the if(PIR) the flag of the USART wouldnt be activated if for some reason it was called during the other process.
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.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
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?