[En-Nut-Discussion] SPI in IRQ

Klaus Kloos klaus.kloos at gmx.de
Thu Feb 16 08:22:36 CET 2012


Hello

I have to work with an 24bit ADC AD7767 with 32kSPS.
The values can be read between two finished conversions from the device using SPI. There are ca. 30us left for this when using the 32kSPS.

My first though was to get the 'value ready' signal by IRQ, inform a thread by NutEventPostFromIrq() and get the value by SPI in a separate thread. But that is much to slow. Im not able to guaranty a context switch in this short time.

The second approach was to get the SPI-value in the IRQ by bitbanging. This is a little to slow and very ugly. I will have to code this part in assembler.....

So I tried to use the NutOS functions. (*spiBus1At91.bus_alloc) and (*spiBus1At91.bus_release) are called outside the IRQ,  (*spiBus1At91.bus_transfer) is called at IRQ time.
The transfer of the 3 bytes last ca. 12us using 10MHz SPI. It is working, but unreliable. Sometimes my device freezes.
Im almost sure that the SPI-functions are not designed to be used like this.

What are my possibilities? Is there a recommended way to solve such time-critical SPI-requests?
Can I get the Nut/OS functions IRQ save somehow?

Thanks in advance for any hint.

Greetings Klaus

Ingenieurbüro Kloos
Soft+Hardware Entwicklung
Haus Heyden Strasse 111
52134 Herzogenrath
Tel.: 02407/918376
Handy.: 0176/20925123









More information about the En-Nut-Discussion mailing list