code8825 / arduino

Automatically exported from code.google.com/p/arduino
Other
0 stars 0 forks source link

SD Library doesn't setup SPI pins on Leonardo #931

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Connect SD or MicroSD reader to hardware SPI pins (MISO,MOSI,SCK) and SS to 
pin 4 (or your choice)
2. Load any example
3. Watch card init fail

What is the expected output? What do you see instead?
Card should init, example code should run.

What version of the Arduino software are you using? On what operating
system?  Which Arduino board are you using?
1.0.1, ATMEGA32U4 breakout + adafruit MicroSD breakout. OS X Lion

Please provide any additional information below.
If the hardware pins are set to output manually or by another library using SPI 
the SD library works fine.
Adding pinMode(MOSI, OUTPUT) and pinMode(SCK, OUTPUT) before running SD.begin 
is sufficient (hardware SS is already set to output by Leonardo USB Serial 
interface).

Problem can be fixed by changing utility/Sd2PinMap.h to include Arduino.h and 
using code such as:
uint8_t const SS_PIN = SS;
uint8_t const MOSI_PIN = MOSI;
uint8_t const MISO_PIN = MISO;
uint8_t const SCK_PIN = SCK;

Can also remove the code that looks like above from each type of micro 
controller block in Sd2PinMap.h and add above code to Sd2Card.h like new beta 
SdFatLib.

Original issue reported on code.google.com by j...@blackcatmicro.com on 30 May 2012 at 7:11

GoogleCodeExporter commented 9 years ago

Original comment by dmel...@gmail.com on 30 May 2012 at 2:03

GoogleCodeExporter commented 9 years ago
https://github.com/arduino/Arduino/commit/34b265ed4c8a1c45ec5794f31b60ff2af53182
28

I think this fixes the problem but my SD card seems to be having other 
problems.  Can you test?

Original comment by dmel...@gmail.com on 22 Jun 2012 at 4:30

GoogleCodeExporter commented 9 years ago
Hoping this solved the problem!

Original comment by dmel...@gmail.com on 15 Jul 2012 at 1:15