Go Down

Topic: SK Pang dmx / sd shield + mega2560 (Read 1 time) previous topic - next topic

mrboni

Hi, I'm having a strange issue with this sd shield, and have been trying different combinations, using the card info sd example -

Uno + Ethernet Shield - Chip Select(4), pinmode output(10) - working
Uno + SKP dmx/sd shield - Chip Select(10), pinmode output(10) - working
Mega2560 + Ethernet Shield - Chip Select(4), pinmode output(53) - working
Mega2560 + SKP dmx/sd shield - Chip Select(10), pinmode output(53) - NOT working..

With this last combo I've tried many combinations of CS and Pin Output values.  The dmx out of this shield is working fine, as does the sd when used with the Uno. Confusing!

Any ideas?

fat16lib

The Ethernet shield connects to the SPI bus through the ICSP connector so it will work with a Mega.

The Arduino DMX Shield appears to use pins 10 - 13.  These are not SPI pins on the Mega.

It may be possible to use software SPI on the Mega.

Edit the Sd2Card.h file in the libraries/SD/utility folder.  At about line 42 set MEGA_SOFT_SPI to one like this.
Code: [Select]
#define MEGA_SOFT_SPI 1

mrboni

Ah, interesting.

Changed the line but no joy. 

Anything else to try or do I have to physically link the appropriate pins on the dmx shield to pins 50-53 on the mega?

mrboni

#3
Jun 08, 2012, 07:08 pm Last Edit: Jun 08, 2012, 07:14 pm by mrboni Reason: 1
Whoa, it is working.

Was being a numpty :)

Thanks


edit: seems it's way slower to open the file now though. I take it physically connecting to the hardware spi pins will be faster?

fat16lib

#4
Jun 08, 2012, 08:07 pm Last Edit: Jun 08, 2012, 08:12 pm by fat16lib Reason: 1
Hardware SPI will be faster but open time depends a great deal on where the file to be opened is located in the directory.

Hardware SPI is 4 MHz and software SPI is about 1 MHz for SD.h but you will probably get only a factor of two speed-up at most for read/write and even less for open().

You will see almost no improvement if you write to an SD using print.  All the overhead is in formatting numbers, not in transferring data over the SPI bus.

Go Up