0

I'm using a Bluefruit nRF52 with Arduino framework, and using Bluefruit library. It's connected to the Bluefruit connect app, but also acting as an SPI slave for another device (an stm32).

I'm having to bit-bang the SPI as the Arduino SPI library won't work as a slave (for nordic nrf52 devices), and using a GPIO from the nRF52 to tell the stm32 I'm ready to receive SPI (normally 5 to 10 bytes), after it detects SPI nCS assertion. To bitbang the SPI data, I'm then waiting on an interrupt on rising edge SPI CLK, at which point clock in the MOSI data.

It's mostly working except the odd message (1 in 5ish full transfers) gets missed. I've traced this to one SPI clk interrupt being missed during the transfer. (each transfer is 10 bytes).

As the nrf52 softdevice has higher priority than any user code, including interrupt handlers - I'm wondering if the irq is being missed because it happens during a period where the softdevice is in control. which is asynchronous.

So I'm wondering if I wait until soft device takes control, then wait till its done, then I signal that I'm ready to receive over SPI, that will give me the best chance to receive a full message.

Is there a way that I can poll some flag / variable / register to know that the softdevice has just been busy?

jsotola
1,5342 gold badges12 silver badges20 bronze badges
asked Dec 18, 2023 at 16:42
2
  • It has SPI Slave (SPIS) with EasyDMA so you could just use that instead. But I suppose you are afraid of events and tasks and that semaphore Commented Dec 20, 2023 at 9:52
  • Hi KIIV thanks for the reply. i can see the SPIS in the nordic low level files but its not implemented in the arduino SPI library. i tried to make my own version (SPI.h and SPI_nrf52832.cpp) to handle SPIS but couldnt get it to work. Commented Dec 21, 2023 at 13:54

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.