Problem with NativeSPI.dll

  • 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):



    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)



    Nothing seems to work lately on the PicoComA5: serial comms (e.g RTS), capacitive touch screen and now SPI :-(

  • Ok, sorry for the misrules,
    But "native" means only the the SPI is a part of the processor and the lines are not emulated via GPIO. I will check your action and answer here later. I assume you use VS2008 because of CF3.5?


    PS. By the way with new Serial Driver RTS works.

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Hello,


    - you don't have to install the driver at all, it is already installed.
    - sorry, following "test" does not work, Because only polling method is implemented. For that after the first loop you get "ERROR_INVALID_FUNCTION". So please don't change the drivers method:

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • You have registered "DriverMethod"=0. As i outlined above this is not possibel. So please switch to "POLLING" before call other IOCTLs or use the default registering. The class definitions are available for you, when set cursor to a define and press F12:


    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • OK, I thought POLLING was default - I have changed that and now it seems to work so I'm reasonably happy.
    The fact remains though that you ask 500 euro for a software package that


    * comes with no documentation


    * the documentation on your site is incorrect: it says "The easiest way to install the driver is to use the provided
    Windows Cabinet File nspi.cab." and it says to set DriverMethod to 0


    * comes with incorrect sample code that can never work


    That is not impressive! It has also beomce my experience of F&S: when things work they work well but nothing (or little) works straight away.
    Some recent examples: NativeSPI, serial driver, capacitive touch screen


    Two of these have now been solved (it seems) but the touch screen still doesn't work ...

  • I am not disagree in all points you outlined here.
    But please keep in mind "sample code" serves as a template. And we assume that our customers can debug and measure ....and we try to support very fast. Note we provide industrial boards with very flexibel interfaces.

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • True enough but I think that "sample code" should at least work, otherwise it's not a good template.
    And I can test and debug and measure but it's not easy when the documentation tells you the wrong thing.


    And yes, I do appreciate that your platform is flexible and therefore complex, it's just frustating when the days go by waiting for solutions.


    And yes, your support is mostly good :-)

  • It seems the ReadMemory, or better said, the nspi.Receive doesn't work properly:


    int ires=nspi.Receive(command, out data, count);


    where command is MEM_READ,0,0 and count is 32


    What I get is this output from the application:


    Code
    1. NSPI version=V3.0
    2. Read memory at 0
    3. ReadMem: return code=32, GetLastErr=87
    4. Read result=
    5. FF-FF-FF-FF-FF-FF-FF-FF-FF-FF-FF-FF-FF-FF-FF-FF-FF-FF-FF-FF-FF-FF-FF-FF-FF-FF-FF-FF-FF-FF-FF-FF


    I check the return code of Receive and if it's not 0 (and it isn't, Receive seems to return the value of 'count') I call GetLastError.
    The fact the Receive returns the count makes me think it isn't an error but why then do I get an error code from GetLastError?


    87 is ERROR_INVALID_PARAMETER but which one, there are only three. Unless the error happens in Receive itself.
    Again the problem is lack of documentation - I have no up to date documentation telling me how to use a v3.0 NspiPort


    So what goes wrong?


    And, by the way, what should nspi.SpiMode and nspi.ClockFreq be set to?

  • OK, no reaction to any of my latest posts so I'll try again:


    * What pin numbers do the NativeSPI DLL v3 expect? 26-29?


    * Can I tell the NspiPort class to use other pins and, if so, how? And if not possible, how can I use the DLL for more than one SPI device?

  • Using a PicoComA5 board, a 25LC256 Microchip EEPROM and your NativeSPI library V3, including the sample app, we have checked what happens on the SPI lines during communication with an oscilloscope.


    We are using SPI1 and have set CSPin to 11 (decimal). It isn't clear whether the line should be specified as IO-pin (11) or PCA5 pin (29) so we have tried both. The other lines (MISO, MOSI and CLK) were connected to the standard pins 26-28.


    All pins except CLK had external pullups.


    What we see is that CS never goes low, neither during read nor during write. So either something is wrong in your library or the library is not using the pin specified in CSpin. All other lines (i.e. SI, SO and CLK) showed up nicely on the oscilloscope.


    To check our connection to the CS pin of the EEPROM we disabled SPI and configured pin 29 (port 1, pin 3) as GPIO and wrote code to toggle it: worked perfectly.


    Questions:


    1) How is CSpin to be specified, as IO-pin or PCA5 pin?


    2) Why don't we see CS going low during read and write actions?


    3) Does NativeSPI use some other pin for CS?

  • Quote

    1) How is CSpin to be specified, as IO-pin or PCA5 pin?

    You have to do nothing at all. Pin 29 should be CS by default.

    Quote

    2) Why don't we see CS going low during read and write actions?

    I am back in the office at 22.4.14 i will check it than. But it is stange, because we have only to register the CS all other things should be done by the processor. Maybe there is a bug in the driver ... .

    Quote

    3) Does NativeSPI use some other pin for CS?

    At the time only one pin is usabel. But we can expand the driver so that more than one pin is useable as CS.

  • 1) But I can use CSpin to specify CS can't I? If I don't want to use 29 or if I have more than one SPI device, in which I must have different CS pins


    3) Do you mean the driver always uses 29 and ignores the value of CSPin? And 29 is the pin number on the PCA5 itself?

  • Hello,
    i used latest kernel for my quick test (140414). I can not see any error. CS works as expected.


    - Only pin 29 is usabel as CS, you cannot use another pin (with the current driver). This pin is used by default, no additional settings are required or applied.
    - Pin 29 is the pin number on the PCA5 itself! Refer HW doku pin 26-29 for SPI. I think you use already the right pins else you would see nothing at all.
    Maybe a register setting overwrites the CS function. Please try to reset you registry to default.


    If you need more as one CS we have to expand the driver. The processor offers only four dedicated pins for each SPI. But on demand we can implement more than one CS.

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • I'm using the december 2013 kernel, do you know if that should work as well?


    I did a registry reset not long ago and has changed very little since, I don't think that will help. The only thing that can get in the way is CAN (correct?) and I have disabled that. But I will double-check that 29 isn't used somewhere else.


    You write "Only pin 29 is usabel as CS" but that is strange because this is what the documentation says



    So what is right and what is wrong?

  • Quote

    You write "Only pin 29 is usabel as CS" but that is strange because this is what the documentation says

    Quote

    So what is right and what is wrong?

    Hm, i said already several times that this driver can use only pin 29 as CS. I checked the source code and you said you use pin 29 for CS. But we can expand the driver if required. The current driver does not fulfil the documentation.

    Quote

    I'm using the december 2013 kernel, do you know if that should work as well?

    I please you to update bootloader and kernel. Because the older version should not be used for mass production, so i make no sence that i test the older Versions. But i saw not changes in the changelog concerning this subject. So i think SPI has the same function since kernel 0.2.

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.