|
|
View previous topic :: View next topic |
Author |
Message |
New user Guest
|
manual interrupts |
Posted: Wed Mar 31, 2004 9:34 am |
|
|
I am new tot he compiler, can someone help me out??
I am manually enabling TMRO interrupt, and testing to see if the TMR0
flag has gone high within the global ISR()
#int_global
I KNOW THAT I COULD USE THE SPECIFIC #int_RTCC, but I want to
try using the global ISR.
MY QUESTION IS:
I KNOW THAT I HAVE TO DO THE FOLLOWING IN A GLOBAL ISR
test flags
clear flags
I have read somewhere you need to save the status of the registers
prior to entering the subroutine (WHEN?, HOW?,WHICH REGISTERS?) |
|
|
valemike Guest
|
|
Posted: Wed Mar 31, 2004 10:15 am |
|
|
All the registers are saved for you by CCS when you implement a your isr. Just make sure it is a "void fxn_name(void)".
If i have more than one interrupt source, then i usually just write two separate functions and use the appropriate #int_ext or #int_timer1 directives.
I don't have the manual in front of me, but I don't think there is a way to make a global isr. The Global Interrupt bit GIE (from mem.?) merely enables all selected interrupt sources or turns off all selected interrupt sources.
You really ought to do it the way CCS has prescribed for us. But if you want to try making a global isr like the assembly folks usually do, where they then sort out which is the active interrupt, then I think you'll have to write an isr routine and force its start address where the interrupt vector is for that device. Thus if, the interrupt vector starts at address 0x04, then you place your function starting at 0x04 in program memory. Then I guess you'll have to do all the register saving and restoring manually. |
|
|
Ttelmah Guest
|
|
Posted: Wed Mar 31, 2004 10:45 am |
|
|
valemike wrote: | All the registers are saved for you by CCS when you implement a your isr. Just make sure it is a "void fxn_name(void)".
If i have more than one interrupt source, then i usually just write two separate functions and use the appropriate #int_ext or #int_timer1 directives.
I don't have the manual in front of me, but I don't think there is a way to make a global isr. The Global Interrupt bit GIE (from mem.?) merely enables all selected interrupt sources or turns off all selected interrupt sources.
You really ought to do it the way CCS has prescribed for us. But if you want to try making a global isr like the assembly folks usually do, where they then sort out which is the active interrupt, then I think you'll have to write an isr routine and force its start address where the interrupt vector is for that device. Thus if, the interrupt vector starts at address 0x04, then you place your function starting at 0x04 in program memory. Then I guess you'll have to do all the register saving and restoring manually. |
There is an example on using the #int_global included with the compiler. ex_glint.c
The registers you have to save, depend entirely on what you do. For instance, on the 18F famiy, the default handler saves W, status, BSR, and then goes ahead, and saves the table pointers, FSR registers, and the scratch area. You can save a _lot_ of time, by not saving these, if you write your ISR not to use them. The table pointers are used for array accesses, and switch statements using a table jump. The scratch area is used when calling a subroutine which returns a value, and some larger arithmetic operations. If (for instance), you are handling a simple operation, and keep it down to just integer increment/decrement type operations, you can reduce the interrupt latency by as much as 10 instruction times, by not doing the save.
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|