Page 1 of 2

SPI documentation

Posted: 04 Nov 2016 09:38
by A.Harrenberg
Hi PoltoS,

the online documentation for SPI has some 404 pages, at least SPISetting and Due Extended SPI usage.

For SetDataMode there are 4 possible values for the mode named, but not described. It is written it is clock polarity and phase, but which mode is which combination?

Would be great if you can check and update the documentation.

I have a cheap MFRC522 RFID reader which uses SPI and I would like to connect it to the Z-Uno...

Regards,
Andreas.

Re: SPI documentation

Posted: 09 Nov 2016 09:14
by A.Harrenberg
Hi,

so for the modes it seems that this is the standard definition for the polarity and the phase:

Mode CPOL CPHA
0 0 0
1 0 1
2 1 0
3 1 1

Regards,
Andreas.

Re: SPI documentation

Posted: 13 Nov 2016 13:32
by PoltoS
Thanks, fixed the doc

Re: SPI documentation

Posted: 13 Nov 2016 22:43
by A.Harrenberg
Hi PoltoS,

in the documentation for SPI the call for SPISettings or SPI.beginTransaction() is described as

Code: Select all

SPI.beginTransaction(SPISettings(14000000, MSBFIRST, SPI_MODE0)); 
, but this does give an compiler error:

Code: Select all

no viable conversion from 'SPISettings' to 'SPISettings *'
In the SPI lib for the ZUNO the beginTransaction is defined as

Code: Select all

void beginTransaction(SPISettings * settings);
, in the SPI lib for the Arduino it is defined as

Code: Select all

inline static void beginTransaction(SPISettings settings)
I tried to adapt the ZUNO lib, but it seems that with the sdccp compiler only a pointer is allowed.

So I use

Code: Select all

SPISettings SPIS(4000000, MSBFIRST, SPI_MODE0);
to initialize the settings (by the way, in the example there is a "14000000" given, which seems to large...) and then just pass the pointer to SPIS to beginTransaction():

Code: Select all

      SPI.begin();
      SPI.beginTransaction(&SPIS);
Is that the intended way? If yes, then the documentation should be adapted. If not, how to do it correctly?

Best regards,
Andreas.

Re: SPI documentation

Posted: 14 Nov 2016 23:15
by PoltoS
This is correct, we can not pass objects as parameters but reference (pointer) only. The API is slightly different from Arduino.

14MHz looks like a typo. Fixed

Re: SPI documentation

Posted: 16 Nov 2016 00:24
by A.Harrenberg
Hi PoltoS,

thnx for fixing the documentation, but the description for SPISettings is still showing the "old" syntax with the object:

Code: Select all

SPI.beginTransaction(SPISettings(14000000, MSBFIRST, SPI_MODE0)) 
Would be great if you can update that as well.

Regards,
Andreas.

Re: SPI documentation

Posted: 26 Nov 2016 12:21
by PoltoS
Done. We will soon make an example with SPI.

Have you made something meanwhile

Re: SPI documentation

Posted: 26 Nov 2016 12:37
by A.Harrenberg
Hi PoltoS,

working with the simple library for the RCF522 is not successfull, the sketch is resetting after a while or when I present the tag to the reader. I gave up on this one and will try again if you release a new version, I can only think of some internal problems. This is described here.

In the meantime I tried to convert a larger library for the RFC522 from the Arduino to the ZUNO, but I am also stuck there. I end up with an "unknown error" saying that the index for the list is ouf of bounce, but there is no linenumber, so I can't find the issue... This is described here

Other than these two failed attempts I did not work with the SPI library.

Will the new example for the SPI come along with a new version of the ZUNO? :?: Are there plans for the next release?

Regards,
Andreas.

Re: SPI documentation

Posted: 26 Nov 2016 13:02
by PoltoS
We have changed nothing in SPI, so the example will work with the existing too.

We have fixes some potential problems and will release the new version next week.

From what we see, most problems arise from stack overflow. We will soon add some "debugging" tools to notify user about stack overflow and some other problems.

Re: SPI documentation

Posted: 26 Nov 2016 13:04
by PoltoS
May be try to minimize the number of wrapped function calls and make more global variables instead of local. This will free some stack.