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

issues with implementing SPI slave on nrf9160DK

using nrf connect sdk 1.4.0 and nrf9160 DK

build: nrf9160dk_nrf9160ns

SES version: V5.10d

Windows 10 Pro 64bit

1. Please note I used https_client project to implement spi slave(but have removed all the https code.. ignore the cert file)

2. Used some details from tickets this and this.. Please trust me when I say i have searched the devzone and documents as much as I could

proj.conf looks like this

# SPI
CONFIG_SPI=y
## for slave only
CONFIG_SPI_SLAVE=y
CONFIG_SPI_3_OP_MODES=3

#commented these out as per some devzone discussions
#CONFIG_SPI_3=y
#CONFIG_SPI_NRFX=y
#CONFIG_SPI_3_NRF_SPIS=y #this gives an error while opening a project if uncommented


CONFIG_RESET_ON_FATAL_ERROR=n

overlay file

&spi3 {
compatible = "nordic,nrf-spis";
status = "okay";
mosi-pin = <10>;
miso-pin = <11>;
sck-pin = <12>;
csn-pin = <13>;
def-char = <0xde>;
};

main.c

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
* Copyright (c) 2020 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
*/
#include <string.h>
#include <zephyr.h>
#include <stdlib.h>
#include <drivers/spi.h>
#include <nrfx.h>
#include <nrfx_uarte.h>
#include "nrfx_spis.h"
#define PIN_SCK 10
#define PIN_MOSI 11
#define PIN_MISO 12
#define PIN_CSN 13
#define SPIS_NR 3
nrfx_spis_t spis_t = NRFX_SPIS_INSTANCE(SPIS_NR);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Notes:

I have closed the solution and opened after changing proj.conf. I am using SPIS3

Issue is that nrfx_spis_init fails with error 0xbad0005.. and the reason for that is this line in nrfx_spi.c fails

    if (p_cb->state != NRFX_DRV_STATE_UNINITIALIZED)

I am just confused to see that p_cb->state is set to NRFX_DRV_STATE for some reason
m_cb[p_instance->drv_inst_idx] has valid data... that array has ONLY ONE element (given only spi3 is available)  and drv_inst_idx=0;

It is clear that I a missing some configuration.. I was told to make some spis related changes using the SES ->project->configure nrf sdk project.. I tried to enable spis2 instance and spis3 driver and that made no difference.. I am sure you have some document in there somewhere in your ocean of documents explaining this but unfortunately I couldn't find any details

3. The SPI master worked without any issue.. Not that it helps but just FYI

4. attached the entire project in zip file

4331.https_client.zip