Code Monkey home page Code Monkey logo

Comments (6)

stevstrong avatar stevstrong commented on July 17, 2024

Running the standard SdInfo sketch will also take some time till "freeClusters: " display the result:
uint32_t volFree = sd.vol()->freeClusterCount();

from sdfat.

greiman avatar greiman commented on July 17, 2024

beginTransaction() should set only the SPI speed , bit order, and data mode. begin() will set the default speed/mode but may be slower since the SPI controller will be initialized.

freeClusterCount() must read the entire FAT to find the free cluster count. This will take a long time for a 64G card.

You can limit reading the FAT to the first call by setting this symbol at about line 80 of SdFatConfig.h.

//------------------------------------------------------------------------------
/** 
 * Set MAINTAIN_FREE_CLUSTER_COUNT nonzero to keep the count of free clusters
 * updated.  This will increase the speed of the freeClusterCount() call
 * after the first call.  Extra flash will be required.
 */
#define MAINTAIN_FREE_CLUSTER_COUNT 0

from sdfat.

stevstrong avatar stevstrong commented on July 17, 2024

I tried to set MAINTAIN_FREE_CLUSTER_COUNT to "1" but it did not help, the SdInfo sketch still take the same amount of time to return freeClusterCount(). So I guess this is inevitable for the first time this function is called.

from sdfat.

andreydung avatar andreydung commented on July 17, 2024

Thanks all! I tried a smaller card (32Gb) and with the new method it's down to 3 sec.

I just need to monitor and check that data collection to SD card is working fine. Are there any other alternative statistics that could be performed much faster? I'm looking for the range of 10ms.

from sdfat.

greiman avatar greiman commented on July 17, 2024

The first call to freeClusterCount() after SD.begin() will take a long time.

If MAINTAIN_FREE_CLUSTER_COUNT is nonzero, the time should be much less than a ms after the first call.

Here is the code:

int32_t FatVolume::freeClusterCount() {
#if MAINTAIN_FREE_CLUSTER_COUNT
  if (m_freeClusterCount >= 0) {
    return m_freeClusterCount;
  }
#endif  // MAINTAIN_FREE_CLUSTER_COUNT

from sdfat.

greiman avatar greiman commented on July 17, 2024

closed

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.