Main Site Documentation

Exception of type 'System.Exception' occurred in Microsoft.SPOT.HardWare.dll, FEZ Hydra SPI error


#1

Hi guys,

I was wondering if you could me debug this error.

I have some code that tries to initialize an SPI socket on the FEZ Hydra board.

I have tried stepping through and debugging it but I can’t seem to find the problem.

The line highlighted during the exception is the following: where GTI is equal to the namespace Gadgeteer.Interfaces and GT is the namespace Gadgeteer.

public GTI.SPI AllocateSPI(bool Rising, GT.Socket chipSelectSocket, GT.Socket.Pin chipSelectPin)
        {
            GTI.SPI.Configuration spiConfig = null;
            if (Rising)
            {
                spiConfig = new GTI.SPI.Configuration(false, ChipSelectSetupTime, ChipSelectHoldTime, false, true, ClockRateKHz);
            }
            else
            {
                spiConfig = new GTI.SPI.Configuration(false, ChipSelectSetupTime, ChipSelectHoldTime, true, false, ClockRateKHz);
            }

           [b] return new GTI.SPI(_spiSocket, spiConfig, GTI.SPI.Sharing.Shared, chipSelectSocket, chipSelectPin, this);[/b]
}

Here is the stack trace:

Gadgeteer.SPI.dll!Gadgeteer.Interfaces.NativeSpi.NativeSpi(Gadgeteer.Socket socket, Gadgeteer.Socket.SocketInterfaces.SpiConfiguration configuration, Gadgeteer.Socket.SocketInterfaces.SpiSharing sharing, Microsoft.SPOT.Hardware.Cpu.Pin chipSelectPin, Gadgeteer.Modules.Module module, Microsoft.SPOT.Hardware.SPI.SPI_module spiModule) Line 44 + 0x52 bytes C#

Gadgeteer.SPI.dll!Gadgeteer.Interfaces.SPI.SPI(Gadgeteer.Socket socket, Gadgeteer.Interfaces.SPI.Configuration spiConfiguration, Gadgeteer.Interfaces.SPI.Sharing sharingMode, Gadgeteer.Socket chipSelectSocket, Gadgeteer.Socket.Pin chipSelectPin, Gadgeteer.Modules.Module module) Line 226 + 0x70 bytes C#

ClassLibrary.dll!Colibri.AuxiliaryDevices.ClassLibrary.SPIControl.AllocateSPI(bool Rising, Gadgeteer.Socket chipSelectSocket, Gadgeteer.Socket.Pin chipSelectPin) Line 49 + 0x3e bytes C#

ClassLibrary.dll!Colibri.AuxiliaryDevices.ClassLibrary.SPIBase.SPIBase(Colibri.AuxiliaryDevices.ClassLibrary.SPIControl spi, Colibri.AuxiliaryDevices.ClassLibrary.IOPin chipSelect, bool rising) Line 13 + 0x23 bytes	C#

Pulser.exe!Colibri.AuxiliaryDevices.Pulser.Drivers.AD8369Driver.AD8369Driver(Colibri.AuxiliaryDevices.ClassLibrary.SPIControl spi, Colibri.AuxiliaryDevices.ClassLibrary.IOPin chipSelect) Line 15 + 0xd bytes C#

Pulser.exe!Colibri.AuxiliaryDevices.Pulser.Program.Initialize() Line 89 + 0x130 bytes C#

Pulser.exe!Colibri.AuxiliaryDevices.Pulser.Program.ProgramStarted() Line 54 + 0x16 bytes C#

Pulser.exe!Colibri.AuxiliaryDevices.Pulser.Program.Main() Line 27 + 0x1f bytes C#

If I was to continue debugging I get the following output

WARN: Total initialization time exceeds 10 seconds.
    : ProgramStarted is blocking execution, which means events and timers will not run properly.
    : Make sure not to use blocking code such as while(true) - use a GT.Timer instead.
 Uncaught exception 
The thread '<No Name>' (0x1) has exited with code 0 (0x0).
WARN: Total initialization time exceeds 20 seconds.
    : ProgramStarted is blocking execution, which means events and timers will not run properly.
    : Make sure not to use blocking code such as while(true) - use a GT.Timer instead.

Here is some more Details into the error Message

#### Exception System.Exception - CLR_E_PIN_UNAVAILABLE (1) ####
    #### Message: 
    #### Microsoft.SPOT.Hardware.Port::.ctor [IP: 0000] ####
    #### Microsoft.SPOT.Hardware.OutputPort::.ctor [IP: 0006] ####
    #### Microsoft.SPOT.Hardware.SPI::.ctor [IP: 004d] ####
    #### Gadgeteer.Interfaces.NativeSpi::.ctor [IP: 003d] ####
    #### Gadgeteer.Interfaces.SPI::.ctor [IP: 0055] ####
    #### Colibri.AuxiliaryDevices.ClassLibrary.SPIControl::AllocateSPI [IP: 0039] ####
    #### Colibri.AuxiliaryDevices.ClassLibrary.SPIBase::.ctor [IP: 001c] ####
    #### Colibri.AuxiliaryDevices.Pulser.Drivers.AD8369Driver::.ctor [IP: 000c] ####
    #### Colibri.AuxiliaryDevices.Pulser.Program::Initialize [IP: 00d9] ####
    #### Colibri.AuxiliaryDevices.Pulser.Program::ProgramStarted [IP: 0011] ####

it seems to say that CLR-E Pin Unavailable does anyone know how to fix this error?


#2

Welcome to the forum!

What modules do you have connected to your Hydra?


#3

I’m not currently using any of the GHI modules for this project, I am using custom IC’s for a specialized purpose.


#4

Keep in mind that if you create any managed object that uses a pin. That pin will become unavailable for any other objects, until it is released by the first object. (You can do that by disposing of the object).