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

nRF9160 SPIM Clock not working

Hello everyone,

I'm currently trying to get a SiLabs WF200 WIFI module working with a nRF9160 as the host running on Zephyr. Unfortunately I do not get any clock signal (always on GND) on the selected SCK pin although the MOSI pin is correctly outputting the data. This leads to the WF200 never answering to commands sent by the nRF91.

prj.conf:

CONFIG_GPIO=y
CONFIG_SPI=y
CONFIG_SPI_3=y
CONFIG_SPI_NRFX=y
CONFIG_NRFX_SPIM=y
CONFIG_NRFX_SPIM3=y

I tried different combinations of defines shown in my prj.conf. CONFIG_GPIO is mandatory for other parts of the FW.

nrf9160dk_nrf9160ns.overlay:

&gpio0 {
	status = "okay";
};

&gpiote {
	status = "okay";
};

&spi3 {
	compatible = "nordic,nrf-spim";
	status = "okay";
	sck-pin = <13>;
	mosi-pin = <11>;
	miso-pin = <12>;
};

I this case I tried using different pins without any success. As MOSI is definitely working I tried mapping SCK on that pin but without any success. I have also UART0 and UART1 enabled although they should not conflict with the SPIM3 line.

Bus init:

struct device *spi_dev;
spi_dev = device_get_binding("SPI_3");

SPI send/receive function:

const struct spi_buf tx_buf_header = {
	.buf = header,
	.len = header_length
};
const struct spi_buf_set tx_header = {
    .buffers = &tx_buf_header,
    .count = 1
};
struct spi_buf rx_buf = {
    .buf = buffer,
    .len = buffer_length,
};
const struct spi_buf_set rx = {
    .buffers = &rx_buf,
    .count = 1
};

err = spi_write(spi_dev, &spi_cfg, &tx_header);

if(is_read) {
    err = spi_read(spi_dev, &spi_cfg, &rx);
} else {
    const struct spi_buf tx_buf = {
        .buf = buffer,
        .len = buffer_length
    };
    const struct spi_buf_set tx = {
        .buffers = &tx_buf,
        .count = 1
    };
    err = spi_write(spi_dev, &spi_cfg, &tx);
}

spi_cfg:

struct spi_config spi_cfg = {
	.operation = SPI_WORD_SET(8) | SPI_OP_MODE_MASTER | SPI_TRANSFER_MSB,
	.frequency = 4000000,
	.slave = 1,
};

CS is handled by seperate functions.

I have based my code upon the following example: https://github.com/Rallare/fw-nrfconnect-nrf/tree/nrf9160_samples/samples/nrf9160/spi/ I also tried running the example just like it is. I had to change some things according to the updates that were made to Zephyr since then but SCK was still not working. Loopback (MOSI to MISO) is working like a charm btw.

Furthermore I used information I gathered from other posts here having similar issues but nothing seems to work or help.

I checked, whether the pin is set correctly through the nrfx driver which it was. The Zephyr boot up log shows, that SPIM3 is enabled.

I'm starting to run out of ideas what to do or try.

The nRF52840, which is also on the DK is flashed with stock FW if that matters at all.

These issues occur with or without the WF200 connected to the nRF9160.

I'm using nRF Connect SDK 1.3.0 and Zephyr 2.2 patch level 99.

Parents
  • So to give a small update on this case: I was able to get CLK working now. I do not know what the issue was, maybe it is HW related, but I was able to fix it by using the SPI2 channel instead of the SPI3. Therefore I had to change my .overlay to this:

    &gpio0 {
    	status = "okay";
    };
    
    &gpiote {
    	status = "okay";
    };
    
    &i2c2 {
    	status = "disabled";
    };
    
    &spi2 {
    	compatible = "nordic,nrf-spim";
    	status = "okay";
    	sck-pin = <10>;
    	mosi-pin = <11>;
    	miso-pin = <12>;
    	miso-pull-down;
    };
    
    &spi3 {
    	status = "disabled";
    };

    Note, that I had to disable I2C2 because it was mapped by the default .dts of the DK. Without this i would not be able to use SPI2.

    But nevertheless the communication between the nRF9160 and the WF200 ist not working. MOSI is sending correct data, CLK is working properly, CS is on low when data is being sent, but MISO always stays on HIGH so the value 255 get read into the rx buffer.

    I am also pretty positive that it is not an issue with the WF200 as it works without any problems with the SiLabs EFM32 DK.

Reply
  • So to give a small update on this case: I was able to get CLK working now. I do not know what the issue was, maybe it is HW related, but I was able to fix it by using the SPI2 channel instead of the SPI3. Therefore I had to change my .overlay to this:

    &gpio0 {
    	status = "okay";
    };
    
    &gpiote {
    	status = "okay";
    };
    
    &i2c2 {
    	status = "disabled";
    };
    
    &spi2 {
    	compatible = "nordic,nrf-spim";
    	status = "okay";
    	sck-pin = <10>;
    	mosi-pin = <11>;
    	miso-pin = <12>;
    	miso-pull-down;
    };
    
    &spi3 {
    	status = "disabled";
    };

    Note, that I had to disable I2C2 because it was mapped by the default .dts of the DK. Without this i would not be able to use SPI2.

    But nevertheless the communication between the nRF9160 and the WF200 ist not working. MOSI is sending correct data, CLK is working properly, CS is on low when data is being sent, but MISO always stays on HIGH so the value 255 get read into the rx buffer.

    I am also pretty positive that it is not an issue with the WF200 as it works without any problems with the SiLabs EFM32 DK.

Children
Related