Skip to main content
7 votes

Serial printing from flash memory (F() macro, PROGMEM, sprintf_P, SPTR)

First, the freeMemory() function that you used from Adafruit was originated from a GitHub repository. With the code related to the __arm__ implementation aside, for the code related to the AVR, it is ...
hcheung's user avatar
  • 1,988
6 votes
Accepted

Is there a way to add external RAM (let's say 100 MB or 200 MB) in this audio buffer mixing context?

There are SRAM ICs / boards, however, don't expect 100 MB, more like 1 MB (with the pin numbers and connectivity / protocols that an Arduino offers). With Flash you can get much further, but it can ...
Michel Keijzers's user avatar
6 votes

Locally declared variable takes up global variable space in dynamic memory/SRAM

Isn't the space taken up by the local variable supposed to be freed up from the SRAM once the functions runs because I have declared the variable locally? This is correct. The local arrays you ...
Edgar Bonet's user avatar
  • 45.2k
5 votes
Accepted

Does the bootloader use some SRAM?

You did not specify what type of Arduino you are using. My answer is for the AVR-based ones. The bootloader does use RAM while it is running. However, once it handles control to your program, the ...
Edgar Bonet's user avatar
  • 45.2k
5 votes
Accepted

Does the StringObject.reserve() function prevent memory fragmentation/leaks?

Reserving space will help reduce memory fragmentation, but much of what else you are doing is swamping that small improvement you have made. The biggest area of concern is your cutString function, ...
Majenko's user avatar
  • 106k
5 votes

Locally declared variable takes up global variable space in dynamic memory/SRAM

You must declare the array in global space or static, and make sure the function you pass the buffer pointer to knows it is in PROGMEM. void send22() { static unsigned int irSignal[] PROGMEM= {...
ratchet freak's user avatar
4 votes

Is using malloc() and free() a really bad idea on Arduino?

Is it a really bad idea to use malloc() and free() with Arduino? The short answer is yes. Below are the reasons why: It is all about understanding what an MPU is and how to program within the ...
Mikael Patel's user avatar
  • 7,989
4 votes
Accepted

Is SRAM erased when putting Arduino into sleep_mode_pwr_down?

Generally, Atmega sleep modes do not erase RAM. Their memory is static and as long as voltage (above 2.7V I believe) is applied, data is held. However, this also depends on how you plan to wake up ...
mystery's user avatar
  • 331
3 votes
Accepted

Writing a 1Mb bitmap to an SDcard with only 96kB RAM

You can write the file in chunks. As suggested by ocrdu in a comment, writing line by line is a good strategy. In order to keep the complexity of the code manageable, I would put the logic of deciding ...
Edgar Bonet's user avatar
  • 45.2k
3 votes

How can i reduce my global variable use? Attiny85

FastLED needs to keep the colors of all the pixel in RAM, so that is using a lot of RAM. To get around this, you could use a strategy that generates the pixel data on the fly as you send it out to the ...
bigjosh's user avatar
  • 1,593
3 votes

Which library to use for 23LC1024 SRAM 1 Mbit

This was an excellent challenge for an SPI bus manager and device driver support library I have been working on. Below are some performance results for the SRAM (23LC1024) device driver (Arduino Uno @ ...
Mikael Patel's user avatar
  • 7,989
3 votes

Serial printing from flash memory (F() macro, PROGMEM, sprintf_P, SPTR)

explain in detail what exactly does each of the keywords F(), (PGM_P)F, PSTR, const PROGMEM. F() wraps the string literal in PSTR(...) and then casts it to __FlashStringHelper. This forces it to ...
Majenko's user avatar
  • 106k
2 votes
Accepted

Space needed for local String variable

You are requesting 80 String objects. Each String object allocates memory to store its data. When you provide a string constant that string constant data's length is used for the allocated data size (...
Majenko's user avatar
  • 106k
2 votes

How much can I recurse? How much can I recurse? How much ca!@#QFSD@$RFW

I had this exact same question as I was reading Jumping into C++ by Alex Allain, Ch 16: Recursion, p.230, so I ran some tests. TLDR; My Arduino Nano (ATmega328 mcu) can do 211 recursive function ...
Gabriel Staples's user avatar
2 votes

How is it possible to access the CPU registers using memory addresses?

Microcontrollers tend to be simple compared to processors like you would find in your laptop. Most operating system make use of the higher security features that can prevent user programs from ...
Rudy's user avatar
  • 993
2 votes
Accepted

Using ESP32 Cam internal RAM

If there is continuity between 3.3V and GND your board is dead. Most likely (from my experience) the ESD protection diode on the ESP module is fried which leaves you no chance to repair it. Even if ...
Sim Son's user avatar
  • 1,878
2 votes
Accepted

String(int) function stopping the Arduino

You should avoid String on the Arduino. It will cause random crashes. However that's not your issue. Your issue is trying to copy the data into an array that is too small. char tempSMS2[] = "&...
Majenko's user avatar
  • 106k
2 votes
Accepted

Connect SDRAM to STM32

As far as I know, you have to choose variant with FMC module (Flexible Memory Controller) with SDRAM support - that means you have to use 144pin version STM32F730Z8. The 100pin version does have FMC ...
KIIV's user avatar
  • 4,907
2 votes

RAM cost of entering functions

I guess avoiding functions may have been relevant with dumb compilers, a few decades ago. Compilers today are pretty good at optimizing and, since recently, the Arduino environment enables “link time ...
Edgar Bonet's user avatar
  • 45.2k
2 votes
Accepted

RAM cost of entering functions

A friend has told me I shouldn't rely on functions because, during execution, they occupy a significant amount of RAM. I wouldn't say "significant", but some RAM is used, yes. Every time a ...
Majenko's user avatar
  • 106k
1 vote
Accepted

How can i reduce my global variable use? Attiny85

Since i don't use sysex messages, i got my RAM usage down to 84% by setting the SysExMaxSize in midi_settings.h to 0.
Boyfinn's user avatar
  • 245
1 vote

Writing a 1Mb bitmap to an SDcard with only 96kB RAM

Normally I'd write this a differently, but I've kept in relatively simple just to illustrate the basic idea: struct point { int x; int y; }; const point points_of_interest[] = { { 7, 11}, {23, ...
timemage's user avatar
  • 5,739
1 vote

External RAM (23LC1024) and external Flash (W25Q64JVSSIQ) with Sparkfun SAMD21

You are correct, MISO, MOSI and SCK are common to all the SPI devices. Be sure they are all set up for clock polarity etc. The CS\ line is the select line. If the device is not selected it does not ...
Gil's user avatar
  • 1,863
1 vote

Arduino due temperature reading shows random temperatures

Did you read about this smt160 sensor ? It relies on the calculation of duty cycle of the square wave output from the sensor, to calculate the temparature. temperature = (dutyCycle) -0.32)/0.0047 ...
Mitu Raj's user avatar
  • 424
1 vote

Is there any way I can connect the RAM of a computer to Arduino?

I know this is old, but it comes up on Google so here I am. Forget about connecting any kind of modern computer RAM to an Arduino. Period. However, an old school SIMM from the 80's/early 90's is very ...
Mike C's user avatar
  • 111
1 vote

Possible to determine at runtime whether a pointer is declared PROGMEM?

Is it possible to determine at runtime whether a pointer points to PROGMEM'ed values or regular values? This would give some flexibility when writing code that handles both. The AVR MCUs are Harvard ...
Mikael Patel's user avatar
  • 7,989
1 vote

I'm using too much RAM. How can this be measured?

There is a program called Arduino Builder that provides a neat visualization of the amount of flash, SRAM and EEPROM your program is using. The Arduino builder makes up part of the CodeBlocks ...
sa_leinad's user avatar
  • 3,218

Only top scored, non community-wiki answers of a minimum length are eligible