To avoid struggling with PInvoke and loads of IOCTL, we have purchased the SKIT-VS.NET package. Before I describe the problem I have I need to complain a bit first:
1) The kit is delivered as one zip file with absolutely no documentation for SPI, only the DLL and sample code
2) All SPI docs on the F&S site refer to 'Native SPI' it isn't easy to know what is what
3) The most recent document I have found is <!-- m --><a class="postlink" href="http://www.fs-net.de/download/docu/common/english/NetDCU_NSPI_DOTNET_eng.pdf">http://www.fs-net.de/download/docu/comm ... ET_eng.pdf</a><!-- m -->
It documents "Native SPI V1" and describes NspiPortV1, something which doesn't exist in the current NativeSPI.dll
4) The most recent SPI document is called "Native SPI support" and is from 2013-03-13 but describes interfacing with SPI through CreateFile, ReadFile etc, i.e. using the standard nspi.dll - but again that word "Native"
5) The document at NetDCU_NSPI_DOTNET_eng.pdf says "The easiest way to install the driver is to use the provided Windows Cabinet File nspi.cab". Sounds good but there is no such file included with the SKIT-VS.NET package - installation must be done by hand - not impressive considering the package costs euro 500 ...
Anyway, I have done the install and loaded the sample code, fm25cl64. I upgraded the project to use CF3.5 instead of CF2 and then pressed F5, Start debugging.
The program is built and deployed and runs and then goes bang at nspi.Receive(command, out data, count):
- A first chance exception of type 'System.ComponentModel.Win32Exception' occurred in NativeSPI.dll
- System.ComponentModel.Win32Exception was unhandled
- Message="Error 1 in IOCTL_NSPI_RECEIVE"
- at FS.NetDCU.NspiPort.CheckWin32Error()
- at FS.NetDCU.NspiPort.WaitirqReceive()
- at FS.NetDCU.NspiPort.Receive()
- at FS.NetDCU.Program.ReadMem()
- at FS.NetDCU.Program.Main()
The debug output doesn't add much:
NSPI: Controller 0, SPI_IOControl(): Transmission error (Error 1)
Now, and I don't know if this is important, I don't actually have a FM25CL64 on my board. Instead I have a Microchip 25LC256 - almost but not quite the same although all addresses (READ, WRITE, WREN etc are the same as in the code sample). But can this be the problem?
If the hardware isn't the problem, what is?
Here is what the registry for SPI1 looks like (according to page of the docs)
- REG_SZ Dll FS_NSPI.dll
- REG_DWORD Debug ff
- REG_DWORD RxChannel 4
- REG_DWORD TxChannel 3
- REG_DWORD DriverMethod 0
- REG_DWORD Priority256 67
- REG_DWORD SPIMode 0
- REG_DWORD ClockFreq 30d40
- REG_SZ Prefix SPI
- REG_DWORD Order 65
- REG_DWORD Index 1
- REG_DWORD CsPin 29
- REG_SZ FriendlyName Native SPI driver
- REG_DWORD DeviceArrayIndex 0
Nothing seems to work lately on the PicoComA5: serial comms (e.g RTS), capacitive touch screen and now SPI