CS (chip select) pin location for SD card reader


#1

Hello everyone -

Does anyone know where the CS pin used for SPI (in particular, for an SD card reader) is located on the MegaPi board? On an Arduino Mega, it is pin D53, and the schematic I received from tech support seems to agree with that. But where is it on the physical board? I see on the SPI header (the six yellow pins just below the analog servo pins) there is a RES (reset) pin, but I don’t believe that’s the same pin as CS (and connecting it to the CS output on the SD card reader didn’t work).

Any advice would be very helpful!

Thanks,
Dr. K


#2

A bit of an update, I found a pin that will work as CS (I suspect any digital pin will do, the problem is finding one). If you remove the Bluetooth/2.4g module, then underneath that module are two rows of digital pins (NOT the female pins for the module itself). The pin closest to the yellow analog pins (or equivalently, to the RJ25 shield) and on the row closest to the edge of the MegaPi board is pin 30. You change the code in the SD examples (in the Arduino IDE) to use pin 30 instead of the default and everything works perfectly in the Arduino IDE.

[One caveat: I was not able to get the reader to work with the cheap knockoff microSD cards. I had to buy an actual ScanDisk card (this one is 32GB – I’m looking for smaller). When I used the ScanDisk card everything worked perfectly.]

I’m currently working on an extension (upload mode only) that will allow mBlock5 to access the SD card reader, however, I’ve run into what seems to be a conflict between the encoder drivers and the SD library. Here’s the error message I’m getting when trying to compile:

In file included from arduino-libraries/makeblock/src/MeMegaPi.h:68:0, from C:\Users\subs\mblock-avr\temp\build\code.cpp:4: arduino-libraries/makeblock/src/MeEncoderNew.h:86:17: error: expected unqualified-id before numeric constant #define SDA_PIN 7 ^ arduino-libraries/arduino/SD/src/utility/Sd2PinMap.h:68:15: note: in expansion of macro ‘SDA_PIN’ uint8_t const SDA_PIN = 20; ^~~~~~~ arduino-libraries/makeblock/src/MeEncoderNew.h:88:17: error: expected unqualified-id before numeric constant #define SCL_PIN 4 ^ arduino-libraries/arduino/SD/src/utility/Sd2PinMap.h:69:15: note: in expansion of macro ‘SCL_PIN’ uint8_t const SCL_PIN = 21; ^~~~~~~

Can tech_support provide some insight into how to resolve the conflict? If I could find pin 53 (which is what is supposed to be used for the SPI SS pin), I think there might not be a conflict, but right now, I can’t seem to get the block to compile. Any advice would be welcome!

Dr. K


#3

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.