SPI harware ? Arduino Mega

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

Moderator: Benj

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

SPI harware ? Arduino Mega

Postby cubitus54 » Mon Aug 17, 2015 4:19 pm

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 122 times
These users thanked the author cubitus54 for the post:
Rudi (Mon Sep 21, 2015 6:01 pm)
Rating: 5.26%
 
Flowcode V6.1.2.0(11 05 2015)

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

Re: SPI harware ? Arduino Mega

Postby Benj » Tue Aug 18, 2015 9:54 am

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.
These users thanked the author Benj for the post (total 2):
cubitus54 (Tue Aug 18, 2015 12:30 pm) • Rudi (Mon Sep 21, 2015 6:01 pm)
Rating: 10.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
Contact:

Re: SPI harware ? Arduino Mega

Postby cubitus54 » Tue Aug 18, 2015 12:29 pm

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.
These users thanked the author cubitus54 for the post:
Rudi (Mon Sep 21, 2015 6:01 pm)
Rating: 5.26%
 
Flowcode V6.1.2.0(11 05 2015)