Hi everyone,
although I am new to the forum I have been using Arduino for a long time. I have recently started working on a project using the Nano33 BLE.
I have searched the web for an answer to my problem (including thsi forum) but it seems I only get contracdtictory information.
I am taliking to an ADC (MCP3911) via SPI, the comms work fine but I have some issues:
- 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 closk speed). Please see below a screenshot from a logic analyser (I have tried to lower it and it is fine, I can get lower speeds, but not higher):
- There is a lag of ~ 19-26 us between each SPI.transfer() command, I had not seen this lag on AVR (I have used mostly the Nano Every for the same applicaiton, same code and same ADC). 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.
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):
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);
}
I appreciate your help, thanks!