I have an BLE peripheral application running on a nrf52833 with softdevice S140 were I transmit data from Bluetooth to an external CAN-controller via SPIM and back. This is how the transfer looks like:
- A BLE central is sending max. 232 Bytes to the peripheral which is stored in internal RAM.
- After receive the peripheral is sending the data to the external CAN-controller via SPIM.
- After a certain time the CAN-controller receives the response of max 232byte. It sets a port pin to trigger an event where the SPIM transfers the data to the internal RAM.
- After that the BLE peripheral sends the response to the central.
As you can see both transfers BLE and SPI are separate and cannot interrupt each other.
During a transfer the SPIM is triggered every 125us (CAN=1MBaud) to transfer one CAN telegram.
The transmission via SPIM is handled on the highest possible IRQ-Level (2). So there should be a minimum of interference with the BLE softdevice.
In our application we want very short BLE connection intervals to transfer the data as fast as possible.
Now the problem that I have:
When the connection interval is set to a time below 30ms there is a packet loss on the SPIM.
Like I wrote before the BLE and SPIM transfer are separate so the softdevice has not much to do during the SPIM transfer and the high level IRQs of the softdevice should be so short that this should not be a problem?
The external CAN-controller has a RX message buffer which I can use. So the SPIM must only be triggered for example every 5ms. But this doesn't help.
Despite this, is the softdevices blocking the IRQ for the SPIM transfer too long? (Only empty PDUs are transmitted.)
May be the problem be solved if I use a nrf5340 with 2 cores?