Nano33 BLE SPI speed and overhead

Hi everyone,
I have reached out to the Arduino communitiy about this issue but it seems I might need help from the mbed community as well.

I have searched the web for an answer to my problem (including this forum) but it seems I only get contraddictory information.

I am using an Arduino Nano33 BLE (nRF52840) to talk to an ADC (MCP3911) via SPI. Overall the comms work fine but I have some issues:

  1. The max SPI speed on 33 BLE seems to be 8Mhz, despite the fact that I have read in many places that is should be 32 MHz (1/2 of clock speed). Please see below a screenshot from a logic analyser (I have tried to lower the speed and it is fine, I can get lower speeds, but not higher):

image

  1. There is a lag of ~ 19-26 us between each SPI.transfer() command. Below a screenshot of the logic analyser showing the lag between each SPI.transfer() (I am sending 4 bytes each time, the first is the address, then 3 bytes to read the value fro the MCP3911). Also, the lag is not always the same, it varies. I have read in this post: https://os.mbed.com/questions/82507/Delay-between-SPIwrite-calls/ that there is an overhead in the spi.write() function in mbed, but the answers do not really offer a solution.

image

Has anyone have any ideas? Is there something hidden in the way Arduino implements the SPI from mbed?

In case you ask, here is the routine to read data from the ADC (I am using the library by Ruben J. Stadler), it uses the Arduino SPI functions for mbed:

long MCP3911::read_raw_data(uint8_t channel) 
{
        digitalWrite(CS_PIN, LOW);
	SPI.transfer(ADDR_BITS | (channel << 1) | 1);
	
	byte upper = SPI.transfer(0x00);
	byte middle = SPI.transfer(0x00);
	byte lower = SPI.transfer(0x00);
	
	digitalWrite(CS_PIN, HIGH);
	
	return ((((long)upper << 24) | ((long)middle << 16) | (long)lower << 8) >> 8);
}

Thanks in advance for the help.

A quick search online reveals similar issues. Adafruit have noted this here: Using nRF52840 SPI on Battery Power | Introducing Adafruit CLUE | Adafruit Learning System