SPI slave not working when BLE part is added

I'm using an nRF52832 with SDK v15.3.0 configured as an SPI slave in mode 0, with a master clock speed of 1.25 Mbps. My SPI pin assignments are:


- CS -> P0.06
- MISO -> P0.05
- MOSI -> P0.08
- SCK -> P0.07

I modified the example from peripheral/spis with logs enabled, and it worked fine. However, when I copied the settings from sdk_config to my main application, which also includes Bluetooth functionality, it stopped working. I found no signal on the clock lines.

After erasing and flashing the SPI slave example, it worked again. When I commented out the Bluetooth code and disabled logs, the SPI slave worked, but transactions were missing. I didn’t test it thoroughly after these changes.

Why does the application fail when Bluetooth is active, and how can I fix it?

Parents
  • Hi,

    Have you checked if there may be any conflicting pin assignments in your Bluetooth application? The SPI pinout you have selected is the same as the default pinout used for the UART Do you have logging over UART enabled? 

    Best regards,

    Vidar

  • NRF_LOG_BACKEND_UART_ENABLED, and  BLE_NUS_ENABLED are set to zero.

    NRFX_UARTE_ENABLED and NRFX_UART_ENABLED are enabled. Also in the simple spi slave example they are enabled and disabling it has no effect on my ouput.

  • Thanks for sharing the project. Unfortunately, I have not been able to spot any errors. Please try to log the SPIS events in your code to see which events are triggered:

    it stopped working. I found no signal on the clock lines.

    I'm not sure I understand this. The clock signal is generated by the SPI master.

  • Thank you for the quick reply.

    I connected and disconnected the peripheral(with some pause as I have not implemented a queue in the shared code) and following are the logs generated.

    What I am observing is I am able to receive the connect and disconnect event every alternate time. If I miss connect event, I also miss the disconnect event on the master. Overtime both the signals get missed. This was not happening with the code where ble is not present.

    Following are the logs.

    00> <info> app: Template example started.
    00> 
    00> <info> app: Fast advertising.
    00> 
    00> <info> app: Connected.
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: Fast advertising.
    00> 
    00> <info> app: Disconnected.
    00> 
    00> <info> app: SPIS event: 1
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: Connected.
    00> 
    00> <info> app: SPIS event: 1
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: Fast advertising.
    00> 
    00> <info> app: Disconnected.
    00> 
    00> <info> app: SPIS event: 1
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: SPIS event: 1
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: Connected.
    00> 
    00> <info> app: SPIS event: 1
    00> 
    00> <info> app: SPIS received 1 bytes
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: Fast advertising.
    00> 
    00> <info> app: Disconnected.
    00> 
    00> <info> app: SPIS event: 1
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: Connected.
    00> 
    00> <info> app: SPIS event: 1
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: Fast advertising.
    00> 
    00> <info> app: Disconnected.
    00> 
    00> <info> app: SPIS event: 1
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: SPIS event: 1
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: Connected.
    00> 
    00> <info> app: SPIS event: 1
    00> 
    00> <info> app: SPIS received 1 bytes
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: Fast advertising.
    00> 
    00> <info> app: Disconnected.
    00> 
    00> <info> app: SPIS event: 1
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: Connected.
    00> 
    00> <info> app: SPIS event: 1
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: Fast advertising.
    00> 
    00> <info> app: Disconnected.
    00> 
    00> <info> app: SPIS event: 1
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: SPIS event: 1
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: Connected.
    00> 
    00> <info> app: SPIS event: 1
    00> 
    00> <info> app: SPIS received 1 bytes
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: Fast advertising.
    00> 
    00> <info> app: Disconnected.
    00> 
    00> <info> app: SPIS event: 1
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: Connected.
    00> 
    00> <info> app: SPIS event: 1
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: Fast advertising.
    00> 
    00> <info> app: Disconnected.
    00> 
    00> <info> app: SPIS event: 1
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: SPIS event: 0
    00> 
    00> <info> app: SPIS event: 1
    00> 
    00> <info> app: SPIS event: 0

    I'm not sure I understand this. The clock signal is generated by the SPI master.

    There could be an issue from my end. It is a custom board and I don't have a test pad for debugging, the wore soldered on track could be loose. I have removed it now.

  • Thanks. So the log show that you are receiving both the NRFX_SPIS_BUFFERS_SET_DONE and NRF_DRV_SPIS_XFER_DONE event. The latter indicates that a transaction has been completed.

  • Yes, I am receiving both the buffer set and and transfer done on slave.

    When running the application with BLE, events are getting missed on the master side, and I receive 0xFF. I read the master after receiving an interrupt sent by the slave device(nrf52832).

    What could be going wrong?

  • Please provide the logic or scope trace if you have that.

Reply Children
Related