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

interrupt delay and reset problem

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



Joined: 29 Jul 2005
Posts: 0

View user's profile Send private message

interrupt delay and reset problem
PostPosted: Fri Jul 29, 2005 8:46 am     Reply with quote

Hi everyone.
I am trying to interface PIC16F874 to EPP parallel port, so i have used external interrupt (INT0) pin for this purpose. MCU should response to request in about 10us from start of i/o cycle (start of interrupt) to prevent time-out problem. But CCS compiled codes for starting interrupt (saving some registers) are so long such that it take about 6.5us to enter main routine at 20MH . Is it possible to remove this part of compiled codes? How can I edit compiled codes manually?
I am using a CCS demo version.
Also I have a reset problem, such that I should plug and unplug voltage source several times to reset micro properly. This is the only way that exists to reset it. At other type of resets it don’t work properly.

best regards,
MikeValencia



Joined: 04 Aug 2004
Posts: 238
Location: Chicago

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Fri Jul 29, 2005 11:27 am     Reply with quote

What is your crystal frequency? You can try increasing your crystal frequency to, say, 8MHz, then use the PLLX4 (if it exists on your PIC. Otherwise, find a PIC that supports it) It will now be 100ns per instruction.

The above might work if you only have one interrupt source though. Otherwise, you will have to use 'fast interrupts' and code out that isr yourself. A fast interrupt can interrupt the normal interrupts.

So, you should operate the processor as fast as you could and take advantage of the PLLx4 feature, and learn the #fast_interrupt. I typically just use the regular default ISRs that CCS compiles in, so i don't have any code to illustrate the fast interrupt.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Fri Jul 29, 2005 1:07 pm     Reply with quote

Write you own interrupt handler and save only the registers that need to be saved. Look for #int_global in the help file. The PIC16's don't have the 4x PLL (well, I think there might be 1 of the USB pics's that might).
Ttelmah
Guest







PostPosted: Sat Jul 30, 2005 3:05 am     Reply with quote

And, also don't support the 'fast' interrupt.
The 'key', as as been said, is to se your own global handler.
Generate your interrupt code, and compile it (you presumably already have this). Then look at the listing file, and work out what registers are changed in this routine. If you keep the code really simple (just 8bit addition etc.), then all that needs to be saved is the W register, bank register, and status register. If you do anything more complex, other registers will be affected, and the list will grow. Remember your final code will have to clear the interrupt flag itself.
The place to look, is 'ex_glint.c', in the examples directory, which shows what the global handler has to do.
For a single interrupt source, with the code written to use as few registers as possible, you should be able to get the response down to perhaps 8 instructions. This is an area where the PIC is unfortunately 'poor'. My 'wishlist' for the processor, would have a duplicate set of all the main registers, that can be switched with a single instruction (similar to the structure on the old Z80 processor), which could then be used in interrupts. The 18 family have taken a small step towards this with the ability to automatically save the three main registers for you. Unfortunately, this advantage is then 'downgraded' somewhat by the number of other registers that may need saving...

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