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

Arduino Nano 33 BLE (nRF52840) seems not to run on max. clock speed

We're porting over some software to the Arduino Nano 33 BLE Sense. This board comes with an nRF52840 clocked at a max. of 64MHz. However, the same code runs about 2x slower on this board than on the ST L475VG platform, which also spans a Cortex-M4F (running at 80MHz). This makes me suspect that we're not running the board at the max. frequency (but rather at 16MHz or something). The only place where the main clock is defined seems to be here: https://github.com/arduino/ArduinoCore-nRF528x-mbedos/blob/beac74ca3cd9d07363f66cf9cda6b143e4385cd2/cores/arduino/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/sdk/nrf_drv_config.h#L60, which should be 64MHz. Both targets are using Mbed OS underneath.

Here's a code sample of a pretty simple matrix multiplication in software. We see similar slowdown when using CMSIS-DSP:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "mbed.h"
/**
* A matrix structure that allocates a matrix on the heap.
* Freeing happens by calling `delete` on the object or letting the object go out of scope.
*/
typedef struct ei_matrix2 {
float *buffer;
uint16_t rows;
uint16_t cols;
bool buffer_managed_by_me;
/**
* Create a new matrix
* @param n_rows Number of rows
* @param n_cols Number of columns
* @param a_buffer Buffer, if not provided we'll alloc on the heap
*/
ei_matrix2(
uint16_t n_rows,
uint16_t n_cols,
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

This takes 326ms. on the ST L475, and 2403ms. on the Nano 33 BLE.

Anyone any idea on how we can check the actual frequency without an oscilloscope?

Edit: I managed to speed this up to 786ms. by enabling `-mfpu=fpv4-sp-d16`, setting `-fmloat-abi=hard` (over softfp), and placing and executing the matrix functions in RAM. Still a significant slowdown unfortunately.