if the SS pin is currently INPUT, when you start using the SPI functions the chip goes into SLAVE SPI mode instead MASTER SPI mode. The reason to make the SS pin Output, high has to do with the SPI hardware in the Chip. Why is pin 10 unavailable, when the SS_PIN is 53 on MEGA? The SD card is functioning correctly.īut I want to use pin 10 for a non-SD related task (backlight on an LCD) but as soon as SD is accessed the backlight fails. I don't define SS_PIN as it is set to pin53 and an output by the SD library (in sd2PinMap.h) automatically for a MEGA. The CS_pin is on D8, the microSD default (i.e. The UNO SPI pins 11,12,13 are re-directed in my design. I'm using the MEGA SPI port (50,51,52) to drive a sparkfun microSD shield It has nothing to do with SS.Īn old thread, but the discussion above is exactly where my concern lies.Īfter reading up (again) on SPI I'm still not clear on difference between CS_pin and SS_PIN. The problem is that the Ethernet controller is no longer disabled on the Mega.įor the Ethernet shield you must always make pin 10 an output and high before initializing the SD card. On the Mega, people change the 10 to 53, the SS pin for the Mega, and then the SD on the Ethernet shield will not initialize. Much confusion results from the fact that on 328 Arduinos pin 10 is also SS. So you should make pin 10 an output and set it high to disable the Ethernet controller, not because pin 10 is SS. If you have more than one device on the SPI bus, you must disable all devices other than the SD by making their chip select pin an output and high.įor the Ethernet shield, pin 10 is chip select for the Ethernet controller and pin 4 is chip select for the SD card. Here is the reason you may need to make some pins outputs and high. a general purpose output port (it doesn't influence When the SS pin is set as OUTPUT, it can be used as Set SS to high so a connected chip will be "deselected" by default SS must be in output mode even it is not chip selectĭigitalWrite(SS_PIN, HIGH) // disable any SPI device using hardware SS pinįuture versions of the SD.h library will use the SPI.h library and it also makes SS as an output. Here is the code from Sd2Card.cpp in IDE version 1.01. The SD library always sets SS high as an output so no code is needed for that purpose. or the SD library functions will not work. (10 on most Arduino boards, 53 on the Mega) must be left as an output Note that even if it's not used as the CS pin, the hardware SS pin The SD library has a long history and many of the examples are out of date or just plain wrong.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |