Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 8 of 8

Thread: Interaction between built-in SD card and MFRC522

  1. #1
    Junior Member
    Join Date
    Apr 2021
    Location
    Leicestershire, UK
    Posts
    14

    Interaction between built-in SD card and MFRC522

    I'm having an issue with SdFat using the in-build SD card, an attached RFID reader using the MFRC522 library.

    The project has been migrated from an Arduino, where it has been running for several years using the MFRC522 and an I2C memory chip.

    I'm now switching to using the built-in SD card on the Teensy 3.5.

    The RC522 module is being read, and tag scans being logged to the SD card.

    However the issue I'm getting is as soon as the SD card writes, the MFRC522 library dies and no further reads are possible.

    Using the old I2C chip everything is fine, so I know the core of the system is functional on the Teensy.

    I'm guessing it might be due to them both using the same SPI interface, but I cannot find out conclusively how the Teensy talks to the SD card.

    I'll put together a small test program to show what I'm doing (no way it can be posted at the moment due to the size of the project!).

    In the meantime, is this a known issue?

    How can I make the MFRC522 library use a different SPI interface, or is there a different library that's capable of that?



    Jim

  2. #2
    Senior Member
    Join Date
    Nov 2015
    Location
    Cold hollow VT
    Posts
    201
    According to the schematic https://www.pjrc.com/store/teensy35.html there is no connection between the built in SD Card slot and the SPI bus. Scroll to the bottom of the page.

  3. #3
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,689
    Are you starting the SD card with code similar to this?
    Code:
      if (!SD.begin(BUILTIN_SDCARD)) {
        Serial.println("initialization failed!");
        while (1);
      }
      Serial.println("initialization done.");
    If you use SD.begin(10), Teensy will use the normal SPI interface on pins 10, 11, 12, 13 which will conflict with the MFRC522.

    Pete

  4. #4
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    14,426
    Quote Originally Posted by el_supremo View Post
    Are you starting the SD card with code similar to this?
    Code:
      if (!SD.begin(BUILTIN_SDCARD)) {
        Serial.println("initialization failed!");
        while (1);
      }
      Serial.println("initialization done.");
    If you use SD.begin(10), Teensy will use the normal SPI interface on pins 10, 11, 12, 13 which will conflict with the MFRC522.

    Pete
    Note is SdFat is in use so one examples for SdFat shows this:
    Code:
    // SDCARD_SS_PIN is defined for the built-in SD on some boards.
    #ifndef SDCARD_SS_PIN
    const uint8_t SD_CS_PIN = SS;
    #else  // SDCARD_SS_PIN
    const uint8_t SD_CS_PIN = SDCARD_SS_PIN;
    #endif  // SDCARD_SS_PIN
    With current TD 1.54 Beta SdFat is now included - that code is from an example there

  5. #5
    Junior Member
    Join Date
    Apr 2021
    Location
    Leicestershire, UK
    Posts
    14
    Quote Originally Posted by el_supremo View Post
    Are you starting the SD card with code similar to this?
    Code:
      if (!SD.begin(BUILTIN_SDCARD)) {
        Serial.println("initialization failed!");
        while (1);
      }
      Serial.println("initialization done.");
    Yes, it's using BUILTIN_SDCARD

  6. #6
    Junior Member
    Join Date
    Apr 2021
    Location
    Leicestershire, UK
    Posts
    14
    Quote Originally Posted by defragster View Post
    Note is SdFat is in use so one examples for SdFat shows this:
    Code:
    // SDCARD_SS_PIN is defined for the built-in SD on some boards.
    #ifndef SDCARD_SS_PIN
    const uint8_t SD_CS_PIN = SS;
    #else  // SDCARD_SS_PIN
    const uint8_t SD_CS_PIN = SDCARD_SS_PIN;
    #endif  // SDCARD_SS_PIN
    With current TD 1.54 Beta SdFat is now included - that code is from an example there
    Thanks for the sense-check, SDCARD_SS_PIN is defined as 62, SdFatConfig.h confirms this is for the built in SD.

    The card is working fine with straight calls, it's when I'm in the RFID reading loop things fail.

    Will do some more digging.

  7. #7
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    14,426
    For sure as el_supremo noted though - using that builtin SD card path uses nothing of any shared SD pins - it has distinct 4 bit data SDIO pins for access.

    Accessing the SD card will make some 'noise' and use a good deal of extra power to feed the card's function.

  8. #8
    Junior Member
    Join Date
    Apr 2021
    Location
    Leicestershire, UK
    Posts
    14
    Quote Originally Posted by defragster View Post
    Accessing the SD card will make some 'noise' and use a good deal of extra power to feed the card's function.
    That's something I hadn't considered, will check the supply on the scope!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •