SPI SPCR Errors

Going off of this example, Arduino - Serial Peripheral Interface, I have been getting errors trying to get the Dash to operate in Slave mode with a NodeMCU being the Master.

SPCR |= _BV(SPE); // turn on SPI in slave mode

Does anyone have a work around for this line? I am just needing to transfer data back and forth from a NodeMCU V. 1.0 and a Dash. I2C had issues as well. NodeMCU would talk to a MEGA, Dash would talk to a MEGA, NodeMCU and Dash seem to not like each other very much. I wanted SPI for the full duplex communications.

Thank you,
Jay777

Unfortunately the Arduino SPI library only supports SPI in master-mode. The tutorial you referenced uses MCU-specific registers and interrupts. The Dash uses a 32-bit ARM microcontroller, so the Atmel 8-bit hardware-specific calls can’t be used. The hardware SPI controller used by the Dash does support slave-mode, so it’s possible that you could write your own slave mode driver. I would classify that as an advanced topic, so if you aren’t familiar with register-level MCU programming, I would not recommended that.

Other options you have would be to use the NodeMCU as the SPI slave (if that is supported) and the Dash as the master. The I2C library (Wire) does support master and slave mode. That would require adding pull-up resistors on the I2C lines though. Another option is Serial (UART). The Dash has 2 UARTs available on the IO pins.

I am seeing this issue a lot with the NodeMCU as well. I will try using Serial communications. This should work out fine seeing that they only have to talk a max of four inches.

Many thanks for helping this lego coder and builder get closer to finishing projects!
Jay777