ADXL362 and Electron pinout and sketch questions

Hi all,

I was reading through this thread adxl362 proton and want to do similar but I have an Electron.
Looking at the pinout - the Electron has two SPI so I am confused on the proper wiring and also, what in the code would have to be changed to reflect either of the SPI?

Thanks much,
Kolbi

What are you confused on? Either table will work, it just depends on which SPI interface you want to use.

Mjones,

Thanks much, I was not sure if it was advisable to use one over the other for any reasons unknown to me.

/r,
Kolbi

I tried the following code and wiring but no joy - I just get 0s and -1s for values.

Does the value ‘chipSelectPin = 10’ contained in the adxl362.h need to be changed? Or am I totally off in left field?

Thanks much,
Kolbi

Edited as that quote was for the core, I’m not sure if the pins are interchangeable between the core and photon.

Mjones,

Thanks much for the assist, but I can only get the ADXL362 to work using SPI (on the ADC side - same as the Particle configuration in the previous table above).

Working wiring is as follows:

Now the question is, how can I use SPI1 or SPI2 (C & D pins) for this device instead of SPI? Is this possible and just has to be changed in the code library adxl362.h?

Thanks much,
Kolbi

As it appears the library you are using does not provide any means to select the desired SPI interface, hence you are stuck with SPI unless you find a library that does (e.g. ADXL362DMA) or copy/paste the library files into your project and adapt it (in the .cpp file) accordingly.

On the other hand, there are differences between the SPI interfaces when it comes to maximum speed, but these infos can be found in the docs
https://docs.particle.io/reference/device-os/firmware/electron/#setclockdividerreference

On the other hand, you can have multiple devices on the same SPI bus, you’d just need to select independent CS/SS pins.

1 Like

ScruffR,

Thanks much for the feedback on the different library and SPI speeds. I’ll look into ADXL36DMA.

What really confused was that in the adxl362.h, it has chipSelectPin = 10. Am I’m guessing this refers to Arduino?

/r,
Kolbi

Yup, that seems to be an Arduino remnant, but pin 10 would map to A0 on the Electron.
However, you can choose whatever pin you have available for any of the SPI interfaces.

So should that actually be pin 8 for the electron - for SPI (using A pins)?

It's strongly discouraged to use the anonymous pin numbers.
While you can use them and the mapping D0..D7 = 0..7 and A0..A7 = 10..17 for the Photon (and Electron) allows for a one-to-one translation there are no guarantees that this will be the case for B&C pins nor for future generations (including current Gen3).

On Electron 8 is no usable pin number.

BTW, all GPIO pins (including A#) can be used as standard digital IOs and as said any free digital IO can be used as SS for any SPI interface.

ScruffR,

Thanks much, this does make sense to me now.

/r,
Kolbi