Setting SPI PackedMode causes VybSpi_Open to fail

After a lot of poking and trial and error, I’ve discovered that attempting to set the SPI PackedMode using the WinCE libraries causes the subsequent call to VybSpi_Open to fail. If the call to set PackedMode isn’t made, VybSpi_Open works. I’ve tried settings BitsPerWord before and after the call, and the result is the same.

The basis sequence is the same as in the demo: init, configure, then open. As the code is C#, and split across several files, the projects are attached for testing - the executable program is in Program.cs in the ToradexWrapperTest project.

(FWIW: once verified that it’s working, I’ll be putting the wrapper on GitHub for general use.)

Dear @Monomix

I assume you run into the limitation, that Vybrid only supports 8bit and 16bit word widths in packed mode.
If you use the libraries in debug mode, you should see a message about this in the debug output. The relevant library source code looks as follows:

// vybrid support 8bit and 16bit data bit rate in Packed mode.
if ((vybSpi->packedMode == PackedMode) && ((vybSpi->dataBits != 8) && (vybSpi->dataBits != 16)))
     ASSERTMSG(L"Only 8 and 16bits/word are supported in Packed mode",FALSE);
     return FALSE;

Thinking of it, we could also allow 32bit per word - for this case packed and unpacked mode are identical.

Regards, Andy

Hi Andy, thanks for the super-fast reply.

I’m aware of the limitation, and the error still occurs when:

  • Bits per word is not set explicitly from calling code (and thus defaults to 8)
  • Bits per word is set to a valid value (8 or 16).

So it really appears that enabling packed mode, even with a valid setting for bits per word, makes opening a channel fail.

I’d really like to use packed mode, to avoid unnecessary handling of data before SPI reads and writes.

Can you please upload on a small code sample that generates the issue? That would help us debugging it.

Dear @Monomix,

We have fixed this issue recently. Could you please download and test the preliminary version of the library and let us know your test results.

Thank you for issue reporting and patience.