Continue to Site

# external interrupt speed

Status
Not open for further replies.

#### aruna1

##### Member
guys if i have 12f675 with external 20MHz crystal oscillator what is the maximum external interrupt speed it can have?(within safe margins ,without loosing any interrupts)
is there any theory or equation to calculate this so i can calculate speed for other pics
and does this speed depends on programming language or compiler? (i use CCS C 4.084)

Last edited:
The speed is limited to how long your ISR takes to handle the interrupt. If your ISR was just,

Code:
ISR	bcf	INTCON,INT0IF
retfie
Then it will take 7 cycles to complete and so in theory you could have an interrupt every 1.4uS.

In reality, you would normally have context saving (adds 8 cycles) and some useful code which would take you to a minimum of around 20 instruction cycles which is 4uS.

To work it out, count the cycles taken by your ISR and add 4 (for latency) and divide by 5 (for 20MHz).

Edit, in C you would have to look at the generated code.

Mike.

Last edited:
The speed is limited to how long your ISR takes to handle the interrupt. If your ISR was just,

Code:
ISR	bcf	INTCON,INT0IF
retfie
Then it will take 7 cycles to complete and so in theory you could have an interrupt every 1.4uS.

In reality, you would normally have context saving (adds 8 cycles) and some useful code which would take you to a minimum of around 20 instruction cycles which is 4uS.

To work it out, count the cycles taken by your ISR and add 4 (for latency) and divide by 5 (for 20MHz).

Edit, in C you would have to look at the generated code.

Mike.

well I'm not sure about cycle thing,(i dont know how to count a cycles.i have no basic knowledge i only know to write a code)all i want to do is count interrupts.if count is 10 then do some work

How fast do you need the interrupt to be?

Mike.

well how abut 500khz? is it possible?

Not with a 20MHz clock unless it's doing nothing else.

Mike.

well interrupts routine will using only for about 10seconds.in that time only ting it will do is counting interrupts.after 10 seconds it will turn off interruputs

Why not tell us what you are doing. You may be able to use a counter or something.

Mike.

as i said i'm trying to count pules in incomming signal-a pulse counter

Then use one of the timers.

Mike.

how? can you explain little bit

You configure TMR1 as a counter & give inputs to the T1CKI (GP5).

thanks pommie and gayan

Status
Not open for further replies.

Replies
2
Views
3K
Replies
0
Views
3K
Replies
1
Views
3K
Replies
5
Views
3K
Replies
5
Views
4K