Академический Документы
Профессиональный Документы
Культура Документы
Author Message
Joined: 30 Sep 2004 I would be pleased to here any comments about the speed of execution of interrupts and C code
Posts: 15
Location: Virginia, USA with or without embedded assembly calls. In particular I would like to trigger on the rising edge
of an input TTL and immediately launch an output timing pulse. Can it occur in less than 1 usec?
What is the maximum trigger to trigger timing (phase) variation if this is a repeating stable clock
event? I'm thinking aloud now, but I'm assuming that there would always be a phase variation
of up to 100nsec from pulse to pulse since the incoming trigger could arrive at the beginning of
a system clock cycle or near the end of the cycle.
Project: PIC18F1220 at 40MHz. (25nsec per clock pulse, but this is 100nsec system clock
right?).
When TTL trigger arrives on an interrupt pin, take another pin high for 250usec, followed by
low for 100usec, followed by high for 4.2usec, then low again. The interrupt service routine
could then exit and wait for the next interrupt that is expected in about 16msec.
I have searched the forum for microsecond, interrupts, etc, but I can't locate a definitive
statement about code execution speed with regard to interrupts. I think the ultimate answer will
lead me to programming in assembly and I have very little experience with that.
Thanks, John
I'm sure RJ or PCM Programmer will jump in and correct me but I believe the fastest you can get
Joined: 12 Nov 2003
Posts: 573 into your ISR is around 30 to 40 instructions using the CCS compiler. That requires writing your
Location: Lawrence, KS USA own generic handler and using a combination of the FAST and PRIORITY qualifiers. That was a
flip and off-hand description of the solution.
You might want to consider NOT using an interrupt if your PIC isn't going to be doing anything
except waiting for the edge. Set up a nice tight loop and poll for the edge transition instead.
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
1 от 3 01.3.2007 г. 10:17
CCS :: View topic - Sub microsecond timing http://ccsinfo.com/forum/viewtopic.php?t=27891&highlight=inte...
In my past experience with PicBasic Pro (sorry), assembly interrupts were always faster than a
Joined: 30 Sep 2004
Posts: 15 tight loop looking for a change of state. Is this not the case with CCS C compiled code?
Location: Virginia, USA
In the example given, is this really just as fast as assembly code doing the same task?
Code:
clear_interrupt(INT_EXT);
while(!INTF); // Wait for rising edge
The interrupt dispatcher has to save and restore the state of the program.
Joined: 06 Sep 2003
Posts: 6775 That will always take longer than just polling a register bit.
hansknec wrote:
In my past experience with PicBasic Pro (sorry), assembly interrupts were always faster
than a tight loop looking for a change of state. Is this not the case with CCS C compiled
code?
In the example given, is this really just as fast as assembly code doing the same task?
Code:
clear_interrupt(INT_EXT);
while(!INTF); // Wait for rising edge
Faster.
The interrupt 'response' (time to actually reach the handler), will be slightly faster (at best a
couple of instruction times), but unless your cde only changes the registers automatically
saved/restored using RETFIE1, by the time you have saved even one extra register, the polled
loop will be winning...
Best Wihes
agreed. When I was talking about PBP it was with regard to the ability to have a low phase
Joined: 30 Sep 2004
Posts: 15 variation between captured edges. For some reason, polling the pin would give a horrible result.
Location: Virginia, USA
I understand that this is not polling the pin, but polling a register instead. I need to do some
reading to find out why it would be different for speed.
Thanks, John
The advantage of using the interrupt bit, is the ability to 'see' short signals. With the polled
loop, the bit has to be present for one 'loop time', if it is not to be missed. The interrupt flag
will get set by a signal that is present for just one clock cycle. The jitter will still be worse than
with the full 'interrupt' solution.
2 от 3 01.3.2007 г. 10:17
CCS :: View topic - Sub microsecond timing http://ccsinfo.com/forum/viewtopic.php?t=27891&highlight=inte...
Best Wishes
Thanks, John
Page 1 of 1
3 от 3 01.3.2007 г. 10:17