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

No slave select on SPIM xfer using PPI and GPIOTE

I have a custom board that has an MPU9250 attached as a SPI device. The MPU can generate data ready interrupts. I have set the MPU to generate data ready 4x per second which is about the slowest it can run.

I am using SDK 12.2.0 and I have modified the GPIOTE example under SDK->perpherals. I have set up a PPI channel to start the SPIM xfer on a LOTOHI event of the interrupt pin. I have a second PPI channel configured to toggle a LED attached to another GPIO port when the SPIM_END event occurs.

I have the PPI configured correctly ASFAIK because my LED is toggling, and I can see the interrupts happening on a scope connected to the input pin.

The SPIM is configured to do mulitple XFERs with no increment. (At this slow rate I can respond to the data fast enough) I have a callback defined that does a LOG_HEXDUMP of my rx_buffer and it reads all FFs for the first three transfers and then all 00s thereafter. When I connect a scope to the SPIM pins, my slave select never goes low on the xfers, but the clock is active. Thoughts as to what I'm missing?

I've attached my main.c where everything happens for the sake of this example.

main.c

  • Which pin are you using for SS? Have you tried to use the debugger to see if you hit nrf_gpio_pin_clear(p_cb->ss_pin); inside nrf_drv_spi_xfer()?

  • It is appearing like slave select isn't really under hardware control then. So doing repeated spim xfers triggered by a gpiote pin event really isn't possible without interrupting the CPU. Slave select must go high between each transfer. I can still use the interrupt, but I will probably need to call nrf_spi_xfer again after each single xfer. Can you or someone else with Nordic confirm that this is indeed the case?

  • No, the SPIM does not implement support for slave select directly. Maybe you can try forking the GPIOTE event from the interrupt to a GPIOTE task that sets SS? And forking the SPIM event end to a GPIOTE task that clears the SS? You can fork with nrf_drv_ppi_channel_fork_assign().

  • I will give that a try. If it works I will post here as an answer. I will say, as an embedded programmer with 20 years experience, I like the innovation and functionality Nordic has in this part, but the documentation is scattered and hard to follow at times.

  • Give it a try, and let me know if you get into trouble, and really great if you share your solution. We always try to improve, so if you have specific feedback we love to have it.

1 2