Simple SPI example

#1

I’m going to offload a bunch of buttons / encoders to a nano, then I want to use SPI to connect it to the M2. It woks fine between two nanos, but I’m struggling to configure the M2 as a slave. Can anyone point me to an example that uses SPI for external communication with an M2?

Thanks in advance

#2

You will want to research it a little further but you may want to use a uart to communicate with the M2. The Uart will be a much simpler interface because the SPI is used internally to communicate with some of the devices. I do not believe you will be able to maintain the useage of those devices on the SPI bus if the M2 is not maintained as a master. If you still want to use SPI to communicate with your Nano you MAY have to use the Nano as the slave and the M2 as the master. Regardless, if you can utilize the UART port you will have a much simpler time as it shouldn’t interfere with anything else as it is a dedicated port. Both the SPI and UART are exposed on the external port as well as the XBEE port. (I believe the SPI bus is shared with all devices on the M2 where as each UART port is separate on its own.)

#3

Good point(s). I went down a path that probably wasn’t worth chasing. I can easily read an encoder on the xbee-accessible pins and I’ll try using voltage dividers (like steering wheel controls use) to put more buttons on a single input. I do need to use SPI for a digital pot, so that puts me back in the ‘M2 as master’ realm anyway.