Page 1 of 1

SPI harware ? Arduino Mega

Posted: Mon Aug 17, 2015 4:19 pm
by cubitus54
Hello,

I try to run the SPI connection in hardware mode on arduino Mega
In software no problem, but I have nothing in hardware ...
Software
SPI_soft.gif
(50.55 KiB) Downloaded 812 times
Hardware
SPI_Hard.gif
(45.99 KiB) Downloaded 812 times

Re: SPI harware ? Arduino Mega

Posted: Tue Aug 18, 2015 9:54 am
by Benj
Hello,

SPI hardware on an AVR is a bit weird. If you leave the hardware SS pin floating or pulled low then the SPI will go into slave mode and lockup.

So to use AVR hardware SPI you need to pull the hardware SS pin high or use the pin as an output. The easiest way is to use the SS pin to drive the slave CS pin and that way it is always configured as an output.

On the Arduino Mega 2560 the SS pin is pin B0 or Digital 53.

Re: SPI harware ? Arduino Mega

Posted: Tue Aug 18, 2015 12:29 pm
by cubitus54
Hello,

It works: D

I added the line in AVR_CAL_SPI.c:

SPSR = 0x01; // X 2 SPI: 1US transmission @ 16M Arduino Mega.

It would be nice to add the X2 in the software.