Author Topic: Motenio Mega connecting with SDcard Reader/Writer?  (Read 410 times)

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Motenio Mega connecting with SDcard Reader/Writer?
« on: June 01, 2019, 06:21:13 PM »
     Currently I have been working on a project with an Arduino Mega that I decided I wanted to do some data logging.  Bought a SD card connection board.  And had issues.  Did some reading to find the Arduino Mega has issues with connecting to SD cards.  I have a spare Moteino Mega swap in.  Are there issues with Moteino Mega and reading SD cards?  Any pitfalls to look out for?  Figured I'd better ask before I start moving all my code over to find problems here too. 

Thanks,

MAB

TomWS

  • Hero Member
  • *****
  • Posts: 1877
Re: Motenio Mega connecting with SDcard Reader/Writer?
« Reply #1 on: June 02, 2019, 09:52:47 PM »
There are issues whenever you try to share an SD card with another SPI device. Some work arounds work most of the time, but what works all of the time is to put the SD card on its own SPI bus with dedicated SCK. I've done this with Moteino Mega without any problems.
Alternative is to not use any other SPI device when you're using the SD card. That is, Init SD, open file, do file io, close file, flush SD, and uninit SD. Then do any other SPI  devices.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 5850
  • Country: us
    • LowPowerLab
Re: Motenio Mega connecting with SDcard Reader/Writer?
« Reply #2 on: June 03, 2019, 09:22:34 AM »
Since Moteinos can have a radio module and SPI FLASH-MEM chip, both using SPI with separate SPI_CS pins, why would a third SPI device with another SPI_CS pin not work?
Anything special about SD cards?

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Re: Motenio Mega connecting with SDcard Reader/Writer?
« Reply #3 on: June 03, 2019, 10:30:13 AM »
     Felix,
    I have a MotenioMega I was going to use as my main Main, and it would need to always be listening.  Radio "On"  And of course that would be the same unit I'm using to Log to the SD card.  Now would that be where it would problematic?  Somewhere around here I use to have a chip dedicated to driving a memory card.  I would just pass it data via serial port.  I just can't find it, or remember where I got it. Ahhh.  Still looking.  Thanks.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 5850
  • Country: us
    • LowPowerLab
Re: Motenio Mega connecting with SDcard Reader/Writer?
« Reply #4 on: June 03, 2019, 10:36:56 AM »
Now would that be where it would problematic?
No, I don't know of any problems.
Maybe Tom can give some details how an SD used with native SPI would be problematic.
BTW - MoteinoMEGA uses the Atmega1284p AVR processor and is not the same as Arduino MEGA.

TomWS

  • Hero Member
  • *****
  • Posts: 1877
Re: Motenio Mega connecting with SDcard Reader/Writer?
« Reply #5 on: June 03, 2019, 05:03:59 PM »
@Felix, SD card protocol is not simple SPI sequence. There are modes where clk and sdi are meaningful WITHOUT CS.  Mixed SPI transactions can mess up SD configuration.  There is at least one thread on this forum discussing it from a couple of years ago.  I'm traveling so can't dig it up easily.

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Re: Motenio Mega connecting with SDcard Reader/Writer?
« Reply #6 on: June 03, 2019, 10:03:17 PM »
Well, it sounds like at least have a chance.  I'm already realizing I'm enjoying the smaller package size.  And the radios instead of cabling is so much nicer.  Thanks everyone.