avr-chat
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-chat] SPI interrupt slow?


From: Joerg Wunsch
Subject: Re: [avr-chat] SPI interrupt slow?
Date: Thu, 21 Sep 2006 23:52:48 +0200 (MET DST)

"Steve Franks" <address@hidden> wrote:

> Anyone have thoughts on why I can set an output pin, jam data into
> the SPDR, and clear the output pin on interrupt on a Mega644 (on the
> 8MHz internal clock (SPI at clk/2)), and it takes 7uS, but if I do
> the same with a wait loop instead of the interrupt, it takes 3.5uS?

Interrupt startup takes a documented 5 cycles until the interrupt
vector will be jumped to (unless the interrupted instruction is a
multi-cycle one, when it will take even longer), plus another 3 cycles
for the typical JMP instruction that is placed on the interrupt vector
address.  That's already adding up to a microsecond in your case.

I guess the remainder of your 3.5 µs is due to the ISR prologue, in
particular register PUSHes will take their time (as they access RAM
which will always cost at least two cycles).

> In the real world, this means an AVR can only transfer about 100kB/s
> over the SPI interrupted, ...

Interrupt-driven SPI is really only useful for slow peers.

-- 
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]