CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

using #int_xxxx fast

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
zilog
Guest







using #int_xxxx fast
PostPosted: Sun Jul 01, 2007 8:29 pm     Reply with quote

I have a number of high priority interrupt sources along with a few low priority sources in my system. I want to have internal priority among both groups using the #priority keyword.

What I wonder is what happens to the code, and what I as a programmer need to do to assign one of the interrupts as "fast". The reason for doing this is that this interrupt fires as 112000 times/second, and I will only do some bittest/port update stuff.

As the CCS manual is vague on this topic, could someone please tell me about problems, what machine registers that I can use in my code without saving/restoring them, if I need to manually clear the interrupt flag or if this is done by the compiler, how I return from the fast interrupt etc.

Btw, I intend to write the fast routing in assembler for speed, does this change anything?

I would love examples on how this has been done.
Ttelmah
Guest







PostPosted: Mon Jul 02, 2007 4:10 am     Reply with quote

You can only have _one_ FAST interrupt handler.
The three combinations are:

#INT_xxx

Defines a normal interrupt. The compiler will add the code to save all the registers, then poll the interrupt flags in the order defined by the #priority statement (or the order the interrupts are defined if this statement is not present). The first 'set' interrupt, that is also enabled, will then be called, and the flag cleared (though beware that some interrupts like INT_RB, and INT_RDA, will not be cleared, unless you also perform the required hardware operations). The registers will then be restored, and the interrupt handler will exit.

#INT_xxx HIGH

This defines an interrupt that will be mapped to the 'high priority' hardware handler. These interrupts, can interrupt low priority handlers. The same proceedure exactly is followed for these.

#INT_xxx FAST

This defines a _single_ handler, which will be directly mapped onto the high priority hardware vector. This uses the 'RETFIE 1' return, to restore the W, Status, and BSR registers _only_.

For each handler, the interrupt flag itself, will be cleared, unless the keyword 'NOCLEAR' is added to the declaration.

You can use the 'fast' handler declaration, as if it was a 'INT_GLOBAL' declaration for the high priority interrupts, but then you have to enable the high priority flags yourself for the other interrupts using this handler, and poll the interrupt flags yourself to work out which interrupt is involved.

Beware, that there are a lot of caveats on the chip's themselves, with regards to using the interrupt priorities. In most chips, if high priority interrupts are enabled, INT_RB, will always become a high priority source. Also some sources cause timing problems if combined with the use of high priority interrupts...

Seriously, 112000 ticks per second, is going to be very hard to do. You will need this to be the only high priority interrupt, and the I/O involved must be tiny (no more than a couple of bit operations), if the chip is to be able to do anything else. Even on the fastest PIC's, at 48MHz, you are only going to have 107 instruction times between successive 'ticks'. The interrupt call, and return themselves each use two instruction times. Add the instructions to clear the interrupt flag, and a couple of bit I/O operations, and you will already be using over 10% of the processor time, to handle this. Do anything more, and you will run out of time.

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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