Code Monkey home page Code Monkey logo

Comments (10)

brcnpk avatar brcnpk commented on August 16, 2024

I forgot to mention that the error is: it just cannot read the SD card.

Can't access SD card. Do not reformat.
No card, wrong chip select pin, or SPI problem?
SD errorCode: 0X1,0X0

from sdfat.

greiman avatar greiman commented on August 16, 2024

Your shields will not work with both Software SPI and hardware SPI. Both shields connect to the ISP connector so they use pins 50, 51, 52 for MISO, MOSI, SCK on the Mega.

The SD is not connected to pins 11, 12, 13.

You could use the SD only, not CAN or EtherNet at the same time with software SPI.

from sdfat.

brcnpk avatar brcnpk commented on August 16, 2024

Hi Greiman,
First of all, canbus shield does not have ISP connector like the ethernet. It is connected via pins 9-13. Pin 9 is CS for SD and 10 is CS for CAN. Also, I stack mega+ethernet+canbus and use sofware SPI for CAN on pins 10-13 and hardware SPI for ethernet on pins 50-53 without any problems. In the mean time I can also switch to hardware SPI for SD card on ethernet shield. I want to use CAN shield SD card with mega. Because I will not use Ethernet shield, and want to use CAN + SD from pins 9-13 both with software SPI.

from sdfat.

brcnpk avatar brcnpk commented on August 16, 2024

Just to verify connectivity of SD pins: I used SdFatSoftSpi with ethernet shield on pins 50-53. No problem. Then, plugged in only CAN shield. Did the same, no luck. I am sure about CAN shield SPI pins that they are 9-13.

from sdfat.

greiman avatar greiman commented on August 16, 2024

I have no idea whether you can run both the CAN and SD with software SPI on the CAN card.

You should be able to access the SD card alone if you disable the CAN by setting CAN_CS high.

Looks like CAN_CS is 10 and in your example code above you set 10 to output mode but don't set it high.

Looks like SD_CS on your CAN shield is pin 9.

I test software SPI on mega using an Adafruit Dataloging shield with pins 10-13. I use the SdFat SoftwareSpi example without modification for the test. The AdaFruit shield uses pin 10 for SD_CS.

Try making the following mods to the SoftwareSpi example.

Change the SD chip select pin like this

// Chip select may be constant or RAM variable.
const uint8_t SD_CHIP_SELECT_PIN = 9;

Disable CAN SPI like this

  pinMode(10, OUTPUT);  // <---  ADD THIS
  digitalWrite(10, HIGH);  //  <<--- ADD THIS
  if (!sd.begin(SD_CHIP_SELECT_PIN)) {
    sd.initErrorHalt();
  }

Try running the example.

from sdfat.

greiman avatar greiman commented on August 16, 2024

I edited the above. Make sure pin 10 is set high and only the CAN shield is on the Mega when you run the SoftwareSpi example.

from sdfat.

brcnpk avatar brcnpk commented on August 16, 2024

Here is the result;
2xWin7 PCs, 3xArduino IDEs with different versions with fresh install, Mega+CAN shield only, NO chance.
I switched CAN shield with another one. It worked!!!
However, I do not believe the first CAN shield is wrong because when I plug it on an UNO, with the same code above, it works in SdFatSoftSpi.
Do you have any idea?

from sdfat.

brcnpk avatar brcnpk commented on August 16, 2024

More confusing finding:
I switched mega with a new one. Plugged in the problematic CAN shield. It worked..... ????

from sdfat.

brcnpk avatar brcnpk commented on August 16, 2024

By the way there is no hardware switch or jumper setting available on CAN shield and of course on MEGA. So hardware are all the same and originals from Sparkfun.

from sdfat.

greiman avatar greiman commented on August 16, 2024

I see cases like this fairly often. Experienced users contact me when a problem doesn't make sense.

Often users finally understand the problem, like a bad solder joint on a board or different versions of a part on the board.

Sometimes you only know a board has a problem. Like your Mega could have a problem with one of the software SPI pin connectors. The new CAN shield might make connection because its pins are at a slightly different angle.

Sometimes it's a mystery why two boards don't work together when they work in other situations. If it is my hardware I can't rest until I understand this type problem.

from sdfat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.