Hi I would like to use sdk15.3 with the \nRF5_SDK_15.3.0_59ac345\components\drivers_ext\lis2dh12 but I need to have it with SPI. Is this possible?
Hi I would like to use sdk15.3 with the \nRF5_SDK_15.3.0_59ac345\components\drivers_ext\lis2dh12 but I need to have it with SPI. Is this possible?
Ah, so sorry - I am Old School. i2c (I2C) was the original multi-master, multi-slave, 2-wire communication protocol back in the early 80s and was great for its time. TWI is the same thing (pretty much, only a few differences) and I forget that TWI is now often used as the generic term - particularly with the Nordic teams. It's a bit like DFU - what? Oh, you mean OTA. Times change...
Anyway, to clarify, "get rid of anything with TWI in the name and just use SPI" is what I was suggesting in my earlier posts. All the code you need for SPI I posted earlier, but perhaps start with running a Nordic example as the Nordic engineer suggests. For what you are doing (LIS2DH12 single slave sensor, nRF52832 single master) SPI is much easier than i2c (aka TWI). TWI is inherently slow as it requires the use of open-drain drivers (which allows multiple masters and multiple slaves). SPI instead uses an extra signal to select multiple slaves - Chip Select, usually /CS or NCS. On the nRF52 SPI can run up to 16MHz in single data mode, 4 x faster in quad (QSPI) mode. TWI is slow by comparison, 100kHz or 400kHz typically. The LIS2DH12 runs at 10MHz, 8MHz when used with nRF52832 as 10MHz is not a (supported) option.
The other thing of beauty with SPI is that you cannot possibly get the pins connected wrong (oh yeah ..); unlike serial uarts, for example, which use Tx and Rx. Tx? Tx from who? To whom? Rx from whom? To whom? One cpu/PC Tx is another cpu Rx/Tx so maybe swap the wires around and see if it works better. MISO, only an idiot can get that mixed up with MOSI . Many slaves, single master.
You do not need to use the SPI manager library. I suggest you start with the spi example, remove the old SPI driver and use the nrfx_spim.c driver located in 'nRF5_SDK_15.3\modules\nrfx\drivers\src'.
Here's the necessary SPIM driver API doc.
I suggest you send a couple of bytes from the SPIM and verify that it works with a digital analyzer before you start testing with the lis2dh12.
I added a low-level LIS2DH12 example in this unexpected-events SPIM post which may be of use