# 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:

#### Pommie

##### Well-Known Member
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:

#### aruna1

##### Member
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

#### Pommie

##### Well-Known Member
How fast do you need the interrupt to be?

Mike.

#### aruna1

##### Member
well how abut 500khz? is it possible?

#### Pommie

##### Well-Known Member
Not with a 20MHz clock unless it's doing nothing else.

Mike.

#### aruna1

##### Member
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

#### Pommie

##### Well-Known Member
Why not tell us what you are doing. You may be able to use a counter or something.

Mike.

#### aruna1

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

#### Pommie

##### Well-Known Member
Then use one of the timers.

Mike.

#### aruna1

##### Member
how? can you explain little bit

#### Gayan Soyza

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

#### aruna1

##### Member
thanks pommie and gayan

Status
Not open for further replies.