Summary: Don't use SPIM3 if you are not powering the board via USB.

The nRF52840 has three low-speed SPI peripherals, SPIM0, SPIM1, and SPIM2, and one high-speed SPI peripheral, SPIM3. SPIM0-2 have a maximum clock rate of 8 MHz, and SPIM3 has a maximum clock rate of 32 MHz. (SPIM0-2 are shared with the I2C peripherals, so not all SPI peripherals are always available.)

There appears to be a hardware bug with SPIM3: it does not operate properly when the board is not powered via the USB port. More precisely, it does not work when the VUSB pin to the nRF52840 is not energized.

In Arduino, avoid using SPIM3 if you are not powering the board via USB.

CircuitPython allocates which SPIM to use automatically. The first time you call busio.SPI(), or use board.SPI(), it will allocate SPIM3, so that you get the highest SPI speed possible.

To avoid getting the non-functional SPIM3 when not powering via USB, allocate the first SPI object, which will use SPIM3, and then just don't use it. Allocate a second one for your use, which will pick one of the other ones. For example:

import busio, board
# Allocate and then don't use the first SPI object.
# Choose pins you are not otherwise using. The pins below are just examples.
# You only need to specify a clock and a MOSI pin.

# Will allocate but not use SPIM3. SPIM3 doesn't work when not powered by USB.
do_not_use_this_spi = busio.SPI(clock=board.A0, MOSI=board.A1)

# Will allocate one of the working SPIM peripherals.
spi = board.SPI()

# ...

This bug is being tracked in this CircuitPython issue.

This guide was first published on Jan 18, 2020. It was last updated on Jan 18, 2020.

This page (Using nRF52840 SPI on Battery Power) was last updated on May 13, 2022.

Text editor powered by tinymce.