SPI harware ? Arduino Mega

A forums to allow bugs and problems with Flowcode v6 to be reported and resolved.

Moderator: Benj

Post Reply
User avatar
cubitus54
Flowcode v5 User
Posts: 110
Joined: Wed Jun 19, 2013 7:18 am
Has thanked: 7 times
Been thanked: 32 times

SPI harware ? Arduino Mega

Post 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
Attachments
SPI.fcfx
(5.05 KiB) Downloaded 282 times
Flowcode V6.1.2.0(11 05 2015)

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: SPI harware ? Arduino Mega

Post 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.

User avatar
cubitus54
Flowcode v5 User
Posts: 110
Joined: Wed Jun 19, 2013 7:18 am
Has thanked: 7 times
Been thanked: 32 times

Re: SPI harware ? Arduino Mega

Post 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.
Flowcode V6.1.2.0(11 05 2015)

Post Reply