View previous topic :: View next topic |
Author |
Message |
BlueTower
Joined: 23 Oct 2008 Posts: 29
|
Can I have the same ISR for Timer3 & INT0? |
Posted: Thu Dec 18, 2008 10:31 am |
|
|
Hi. How can I make the pc to jump to one ISR for #INT_TIMER3 & #INT_EXT. Can I do that? Can I have the same ISR for Timer3 & INT0?
Regards |
|
|
ECACE
Joined: 24 Jul 2006 Posts: 94
|
|
Posted: Thu Dec 18, 2008 10:47 am |
|
|
I don't believe you can have them go to the same ISR, but you could have the ISR's execute the same function, which would essentially be the same.
Granted, you probably wouldn't want to be printing from inside and ISR, but you get the point of what I mean?
Code: | #isr_1
{
Common_Function_1();
Common_Function_2();
}
#isr_2
{
Common_Function_1();
Common_Function_2();
}
...
...
...
void Common_Function_1()
{
printf("This is the 1st function common to ISR 1 and 2");
}
void Common_Function_2()
{
printf("This is the 2nd function common to ISR 1 and 2");
}
main()
{
while(1)
printf("not in an ISR right now!");
delay_ms(1000);
} |
_________________ A HW Engineer 'trying' to do SW !!! Run!!! |
|
|
MicroManiac
Joined: 21 Aug 2008 Posts: 34
|
|
Posted: Fri Dec 19, 2008 7:26 am |
|
|
you can use the pre-processor directive
Code: | #int_global
void isr()
{
} |
this will route the all interrupts to this function
but be careful using the compiler does not create the start up code and end code, and so if not being cautious, your system might fail
check with CCS help before you use this function. _________________ "Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction."
Albert Einstein |
|
|
baltazar_aquino
Joined: 16 Mar 2008 Posts: 27
|
|
Posted: Fri Dec 19, 2008 6:10 pm |
|
|
Generally,in PIC MCUs, ISRs are in fact under one "big handler" if you are in the assembly language level. It is the programmer's responsibility to decode which particular part of the MCU hardware triggered the interrupt and then there's the segregation. CCS C just happened to be a higher level language and gives the programmer an easier life by providing segregated ISRs. I have the same suggestion as MicroManiac's. |
|
|
|