I am making a robot where I have an Uno counting encoder pulses and a Mega controlling the robot base and the serial link to the computer. My question has two parts: 1. Is it possible to use SPI if I have interrupts on both pins 2 and 3 on the Uno? And 2. What is the best way to send two longs across SPI?
Thanks in advance,
luketheduke
Are the devices using ithe SPI bus during an interrupt?
No I use a single interrupt for each encoder then set a flag and send the values over spi in the main loop.
I don't think an interrupt in the middle of an SPI transfer matters as long as the ISR doesn't do SPI as well. The SPI clock rate can be just about anything below the maximum for a device in my limited experience. Since I don't have an oscilloscope I sometimes slow the SPI clock down to much less than 1Hz, using software SPI, so that I can watch the transfer with my DMM. The devices don't seem to care. I've wondered how long they would wait for the next clock edge. Maybe forever.
As I am a total newb, would you mind explaining or higlighting some source code that deals with the transfer of two longs from one Arduino to the other?
Thanks,
luketheduke