This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SPI communication with ADXL372

My problem seems to be a lot like case numbers 217967 and 243215.

I do not have an oscilloscope or logic analyzer.

I am using a nRF52840 DK (PCA10056 1.0.0 2018-17) and a nRF52840 (PCA10056 2.0.0 2019-47). I am using the nRF5 SDK v16.0.0 along with the S140 v7.0.1 in a Ubuntu 18.04.3 LTS environment with Segger Embedded Studio and JLink v6.6.0 utilities i.e. J-Link RTT Viewer V6.60f. I have an ADXL372Z breakout board that has headers soldered to it. That assembly is plugged into a standard solder-less breadboard. I'm using the newer DK as a SPI Master. The adxl372 is powered from the DK's VDD to its VS and DK's GND to its GND.

I started out by using the SDK->examples->peripheral->spi and SDK->examples->peripheral->spis. I programmed the older DK as the slave and the newer DK as the master. After some initial confusion such as setting the slave's nrf_drv_spis_config_t->bit_order to NRF_SPIS_BIT_ORDER_LSB_FIRST, I got that working as it should. I also took the time to set up J-Link Viewer specifically so I could use the SEGGER_RTT_WaitKey() function in my main loop. The idea being that the DK waits for me to hit a key before executing any SPI communications. This gives me all the time I need to examine received output.

I know the lack of equipment is a real detriment but I only started on SPI a week ago. (Saleae Logic 8 is getting here). However, I'm confident that the newer DK as the spi master is functioning as it should. I.E. there is a good SCLK and I'm providing the correct buffer sizes and I have a multimeter on the CS line so I know when its high and low.

I moved on to my main goal of using the newer DK board as the SPI MAster connected to the ADXL372 MEMs. I'm using the SDK->examples->peripheral->spi as the basis for my code. My first step was to put a framework together that initializes a nrf_drv_spi_t and configures it to the specifications of the adxl372. My next step was to just read the adxl372's first four registers which contain constant values, (Analog's ID, MEMS device ID, device ID, and the revision ID). This doesn't work. The values returned are incorrect and variable.

The code is attached. You'll need to google the adxl372 data sheet. I would ask for help by looking at my code and providing any advice, hints, help, any pointers. I have tried many different things with no result. I know the adxl372z is good because I can get it to work with an Arduino DUE using the sketches from github.com/analogdevicesinc/arduino. I have tried changing the nrf_drv_spi_config_t fields in many ways and combinations, higher and lower frequencies, different pins (Case ID 127130) (I have stuck with the default pins since they worked for the two DK slave/master setup.) I could really use another set of eyes on my code. Any help/advice is greatly appreciated.

sdk_config.zip

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/**
* Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//
// Thanks to Nordic Semiconductor and bjorn-spockeli for important bits and pieces from
// around 2009, (Nordic Case ID 111509).
//
#include <stdbool.h>
#include "XL372.h"
#include "adxl372_spi.h"
#include "SEGGER_RTT.h"
#include "nrf_drv_spi.h"
#include "boards.h"
#include "app_error.h"
#include "app_util_platform.h"
#include "nrf_gpio.h"
#include "nrf_delay.h"
#include <string.h>
static const nrf_drv_spi_t *p_spi_master_0;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
adxl372_spi.hXL372.h