Arduino Asked by Harini on September 25, 2021
The AnalogBinLogger.ino file of SdFat library says the following:
Each 512 byte data block in the file has a four byte header followed by up to 508 bytes of data. (508 values in 8-bit mode or 254 values in 10-bit mode).
Each block contains an integral number of samples with unused space at the end of the block.
I was wondering why only 254 values can be stored in 10-bit mode instead of (508*8 bits/ 10 bits ~ 406 values ).
The logger will use SdFat’s buffer plus BUFFER_BLOCK_COUNT additional buffers.
BUFFER_BLOCK_COUNT
is 1 for the Arduino Uno since it has 2KB of SRAM. Each buffer is 512-byte long. Is SdFat’s internal buffer also in SRAM? If I am not wrong, the libraries the program uses and the program code reside in the Flash memory, can SdFat write into a buffer in Flash memory?
how will a file-reader differentiate between a 10-bit value taking 2 bytes and two 8-bit values?
The file AnalogBinLogger.h, which comes with the example sketch you mentioned, contains the following:
// First block of file.
struct metadata_t {
unsigned long adcFrequency; // ADC clock frequency
unsigned long cpuFrequency; // CPU clock frequency
unsigned long sampleInterval; // Sample interval in CPU cycles.
unsigned long recordEightBits; // Size of ADC values, nonzero for 8-bits.
unsigned long pinCount; // Number of analog pins in a sample.
unsigned long pinNumber[123]; // List of pin numbers in a sample.
};
Thus, the file reader just needs to be aware of the format of this first
block, and read the recordEightBits
field in order to know whether
this is 8-bit data or not.
Is SdFat's buffer also in SRAM?
Yes, that's the only sensible place you could have a data buffer. It's
allocated on the stack, only during the execution of the
logData()
function.
Answered by Edgar Bonet on September 25, 2021
0 Asked on January 4, 2022 by bobby-tables
4 Asked on January 2, 2022
0 Asked on December 30, 2021 by silencefog
1 Asked on December 28, 2021 by anthony-chan
1 Asked on December 28, 2021 by lucasn
2 Asked on December 24, 2021 by reza-qasemi
0 Asked on December 19, 2021 by yo777
4 Asked on December 16, 2021
0 Asked on December 16, 2021
2 Asked on December 11, 2021
2 Asked on December 9, 2021
0 Asked on December 9, 2021 by girish-ravi
Get help from others!
Recent Answers
Recent Questions
© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP