Go Down

Topic: Adafruit Feather nRF52832 as a SPI slave (Read 312 times) previous topic - next topic


Like the title says, I am trying to configure the Adafruit Feather nRF52 as a SPI slave, who will receive information from a MSP430 microcontroller.

I have found a few code examples that provide solutions to make SPI slaves with arduino :

How do you use SPI on an Arduino?


Unfortunately, both these links provide codes that use instructions like this one:

Code: [Select]
SPCR |= bit (SPE);

and when I try to compile on the arduino IDE, I get error messages like these :

error: 'SPCR' was not declared in this scope

Another person had the same error message and posted about it on stackexchange : https://arduino.stackexchange.com/questions/24134/problem-in-integrating-the-slave-code-in-attiny-84

and the only answer to that post points toward the fact that the chip isn't compatible with this kind of instructions.

I haven't found any SPI examples for that particular chip or board, so as a beginner programmer I'm a bit lost and hoping for some help and guidance as to how I should program a SPI slave without instructions like the one above.

Thank you in advance for your help !

PS: I don't have the login info of our Adafruit account so I cannot ask that question on the Adafruit forums


I have found a few code examples that provide solutions to make SPI slaves with arduino :
The Adafruit Feather nrf52 is not an Arduino (being programmable by the Arduino IDE doesn't make an Arduino). But most SPI slave examples are written explicitly for the AVR platform only (ATmega processors), so the don't work with any of the ARM based boards.
Not all ARM boards support an SPI slave mode. The nrf52 seems to support it though but the documentation is rather poor. Using the NordicSemi SDK you can use it, but I have no clue which parts might work in the Arduino IDE.


Having just been through this, thought I would update this thread with the solution to help others on their search.

The Adafruit nrf52 API uses an SPI class to control this functionality and the SPI Data Register is setup using member functions of that class. So instead of

Code: [Select]


Code: [Select]
// NRF_SPIM_MODE_1 - SCK active high, sample on trailing edge of clock.

Data modes are defined here:
NordicSemi SDK SPI Data Modes

Go Up