Using TinyZero with MicroSD shield

jlastofka

  • Full Member
  • ***
    • Posts: 18
    • View Profile
I'm looking at their example program "listfiles" (attached for reference, it's a small program) and it doesn't work with the TinyZero and MicroSD adapter as written. I think I need to set the proper pin as in the text below from the program:

  SD card attached to SPI bus as follows:
 ** MOSI - pin 11
 ** MISO - pin 12
 ** CLK - pin 13
 ** CS - pin 4 (for MKRZero SD: SDCARD_SS_PIN)

I haven't yet found which pin to use. Or a different way to talk to the SD card?

Anyone have any further information on this? Or a working example? It would be very helpful and appreciated.
« Last Edit: October 25, 2019, 12:27:28 PM by jlastofka »


lennevia

  • Administrator
  • Hero Member
  • *****
    • Posts: 437
    • View Profile
Hello,

First off, the reason you're not seeing any Serial Monitor data from the TinyZero when using the program you attached is because you need to use the SerialUSB object rather than Serial to be compatible with the SAMD21 processor.

The MicroSD TinyShield examples on the Learn page (https://learn.tinycircuits.com/Memory/MicroSD_TinyShield_Tutorial/) make them usable for both the TinyZero and TinyDuino with the following code:

Code: [Select]
// Make program compatible for all TinyCircuits processor boards
#if defined(ARDUINO_ARCH_SAMD)
  #define SerialMonitor SerialUSB
#else
  #define SerialMonitor Serial
#endif

You can use the examples on that page which already work. If you want to adapt the code you attached, the SPI pins are listed on the Learn Page under Technical Details, as well as on the product page:

SPI Interface used:
10 - CS: This signal SPI chip select for the microSD card
11 - SCLK: This signal is the serial SPI clock out of the TinyDuino and into the microSD card.
12 - MISO: This signal is the serial SPI data out of the microSD card and into the TinyDuino.
13 - MOSI: This signal is the serial SPI data out of the TinyDuino and into the microSD card.

Hope that helps!

Best,

RĂ©na


jlastofka

  • Full Member
  • ***
    • Posts: 18
    • View Profile
Thank you. I had found the information about SerialUSB and put in those changes but you read my posting before I removed that part...

I had been looking at several places on the TinyCircuits site but didn't find the one for the SD card reader that you sent. I've now run the example you linked and it runs except it doesn't list the file I have on the SD card. I've put it there from a Windows 7 PC and also from my Mac. So I'll need to look into that some more.

This command doesn't seem to work:
root.ls(LS_R | LS_DATE | LS_SIZE);

I put in a print statement and the program's getting to that point. I made multiple copies of my small data.txt file in case it was a bug where only one file in the root directory won't display. I still need to poke at this some more.


 

SMF spam blocked by CleanTalk