I am working with a music shield, I have got my code from this site https://www.waveshare.com/Music-Shield.htm it works fine with arduino UNO but when I try to use it on MEGA it give me errors, Well I found that the problem is with this line
card.init(SPI_FULL_SPEED,SD_CS_PIN)
in uno SD_CS_PIN=10
I tried to change it to 53
based on this map
SPI Uno Mega
SS 10 53
MOSI 11 51
MISO 12 50
SCK 13 52
which is available on https://forum.arduino.cc/index.php?topic=165170.30 but still it returns false. What other options do I have to make it work on MEGA
?
Thing that I am trying
#define SD_CS_PIN=10
#define VS_XRESET A0
#define VS_DREQ A1
#define VS_XDCS A2
#define VS_XCS A3
void VS10XX::init(void)
{
SPI.begin();
SPI.setClockDivider(SPI_CLOCK_DIV2);
pinMode(53, OUTPUT);
pinMode(VS_XRESET, OUTPUT);
pinMode(VS_DREQ, INPUT);
pinMode(VS_XDCS, OUTPUT);
pinMode(VS_XCS, OUTPUT);
digitalWrite(VS_XDCS, HIGH);
digitalWrite(VS_XCS, HIGH);
reset();
}
In setup I added used this code but still does not work
void setup()
{
Serial.begin(115200);
pinMode(53, OUTPUT);//setting pin 53 to input
player.begin();
}
the error code when I attempt to init
sd card is 0
which says
/** timeout error for command CMD0 */
1 Answer 1
53 is a SS pin if the Mega is SPI slave. Pin 10 is connected to shield to select it as a listening slave. So let the parameter set to pin 10. Additionally on Mega set pin 53 to output, otherwise the Mega can 'fall' into SPI slave mode.
SPI pins 50, 51 and 52 are connected to the ICSP header too. The 6 pin ICSP header is on the same place relative to Uno an Mega common pin headers.
-
thanks very much, Sorry for my noob question, I am new to arduino, So you mean I must set
SD_CS_PIN
to10
and only addpinMode(53, OUTPUT);
afterSPI.begin();
? I updated the questionMajid Hojati– Majid Hojati02/22/2018 13:12:41Commented Feb 22, 2018 at 13:12 -
if it worked with 10 on Uno, then let it 10. for the shield the pin 10 is on the same place on Mega and Uno. 10 is a logical choice for SS on Uno. it must be an output (for the same reason 53 must be output on Mega) if SPI library is used02/22/2018 13:17:10Commented Feb 22, 2018 at 13:17
-
I tried based on what you said but it still returns false. I showed my code in questionMajid Hojati– Majid Hojati02/22/2018 13:18:19Commented Feb 22, 2018 at 13:18
setup()
but still does not work