Go Down

Topic: Arduino Mega2560 SS PIN 53 not working (Read 714 times) previous topic - next topic

AnOuroboros

I am trying to get an SD Card shield up and working and I have seen on the AVR datasheet and other forums that the PINS are different between other boards and the Arduino Mega. I also can see in the library from Arduino (the SD made by Sparkfun) that they have a #if defined(.... _ _ AVR_ATmega2560) and have the pins correctly defined their. However I can only get the board's SS PINS to work when I set it to 10, and then even then when I give it the OUTPUT to tell the hardware AVR about the SPI I can't set the output low only high.

I understand that this is a problem that I can avoid by just keeping the PINS as the other boards defined pins but I am curious on why it's working there.

I'm downloading it using arduino's IDE with the latest version of SD library and Wire.H, and the board has printed on it MEGA 2560, which is selected in the board selection on the IDE.

Juraj

SS pins 10 on Uno, Nano and 53 on Mega are SS pins of the MCU if it is a SPI slave. I repeat "SPI slave".

you can use any free pin of SPI master as CS pin of the slave devices.

on ATmega Arduinos the pin dedicated as SS if the MCU is slave  must be OUTPUT if the MCU is master. the SPI library takes care of that.
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

AnOuroboros

Thank you Juraj for the reply. I have confirmed that the SD Library wont work unless PIN 53 is an output and that like the AVR Datasheet suggests it won't matter if PIN 53 is HIGH or LOW. I am just confused on why the Arduino Mega should care about whether PIN 10 is an OUTPUT or INPUT and why the SD shield will fail if PIN 10 is an OUTPUT and HIGH or an INPUT but work for OUTPUT LOW. I have checked PIN 10 with an LED and it does function.

The only code I have on my project is an LCD code, SD code and a ADC, where the LCD is hooked up through I2C.

Juraj

what SD shield is it? which pin does it use as CS?
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

AnOuroboros

Currently I'm using the PIN 8 as the CS PIN and the shield is the Adafruit Datalogger Shield.

Juraj

#5
Jun 15, 2019, 07:31 am Last Edit: Jun 15, 2019, 07:31 am by Juraj
Currently I'm using the PIN 8 as the CS PIN and the shield is the Adafruit Datalogger Shield.
the shield has CS on pin 10
https://learn.adafruit.com/adafruit-data-logger-shield/wiring-and-config
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

AnOuroboros

OH NO I'm so sorry I saw that in the documentation and re soldered the CS PIN on the shield but I must not have cut the trace properly I just recut it and it is now ignoring PIN 10 like I assumed it should. Thank you so much for helping and being patient!

Go Up