Hi,
I want to make a library, but I use interrupts.
How can I do?
This would be similar to the USB library which also uses the interrupts.
Thank you
Dafra
Interrupts in library
Interrupts in library
Best Regards
Dafra
Dafra
Re: Interrupts in library
Is it so possible ?
library :
void library_interrupt(){
...
}
and in the program
void interrupt {
void library_interrupt();
}
same as the usb library
library :
void library_interrupt(){
...
}
and in the program
void interrupt {
void library_interrupt();
}
same as the usb library
Best Regards
Dafra
Dafra
Re: Interrupts in library
I think you will find that USB_Interrupt_Proc is not an interrupt function per se but is a regular function that is called within the actual interrupt function - check the examples in the help.
As I understand it, there can only be one interrupt routine and it must be in your source file and cannot be in a library. It would be pretty limiting to have the ISR in a library as there are many sources of interrupts and you generally want to be able to write code to handle one or more of them, you could not do that if the ISR was in a library.
It is entirely possible that you could have a function in a library that is called when a certain interrupt is triggered again I would refer you back to the help file for examples (Search for Interrupt).
M
As I understand it, there can only be one interrupt routine and it must be in your source file and cannot be in a library. It would be pretty limiting to have the ISR in a library as there are many sources of interrupts and you generally want to be able to write code to handle one or more of them, you could not do that if the ISR was in a library.
It is entirely possible that you could have a function in a library that is called when a certain interrupt is triggered again I would refer you back to the help file for examples (Search for Interrupt).
M
Re: Interrupts in library
Ok, it's so that I say...
I find the answer with the RFid library...
I find the answer with the RFid library...
Best Regards
Dafra
Dafra
Re: Interrupts in library
Hi,
It is not advisable that you put the interrupts in the library if you are not an experienced user,
as this may lead to some unpredictable results when using it with some other, custom codes.
Regards,
Filip.
It is not advisable that you put the interrupts in the library if you are not an experienced user,
as this may lead to some unpredictable results when using it with some other, custom codes.
Regards,
Filip.
Re: Interrupts in library
Dafra,
you certainly can put a specific ISR in a library, you will need to build it such that i can be simply called from within the interrupt procedure , this ISR should deal with its own flags and leave all other flags untouched. You also need to initialize this with its own Init-function providing all (global!) variables this ISR is using for which exactly the same rules are valid. Depending on the PIC family you will have to deal there with priority's as well. It is obvious that your ISR should be as fast as possible, it may not contain any local variables .
If any of the variables must be visible elsewhere it is gfood strategy to provide functions to access those if any risk of interference between ISR and main code is a risk.
As Filip states, not recommended if you are new to this but absolutely legitimate if you know how to do it.
to Muphy,
no, this is not just an ordinary procedure, it has to deal with interrupt flags at least.
you certainly can put a specific ISR in a library, you will need to build it such that i can be simply called from within the interrupt procedure , this ISR should deal with its own flags and leave all other flags untouched. You also need to initialize this with its own Init-function providing all (global!) variables this ISR is using for which exactly the same rules are valid. Depending on the PIC family you will have to deal there with priority's as well. It is obvious that your ISR should be as fast as possible, it may not contain any local variables .
If any of the variables must be visible elsewhere it is gfood strategy to provide functions to access those if any risk of interference between ISR and main code is a risk.
As Filip states, not recommended if you are new to this but absolutely legitimate if you know how to do it.
to Muphy,
no, this is not just an ordinary procedure, it has to deal with interrupt flags at least.
Au royaume des aveugles, les borgnes sont rois.