STM32L0 - how to check available RAM memory

Post here all questions related to STM32 core if you can't find a relevant section!
Post Reply
Beuzekom
Posts: 15
Joined: Thu Jul 30, 2020 1:32 pm
Answers: 1

STM32L0 - how to check available RAM memory

Post by Beuzekom »

Hi,

I am working on a project using the STM32L082. And during the code execution I would like to monitor the available RAM memory.
Does anybody know if there is a standard function available to monitor the available memory (RAM)?

Thans a lot
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 26
Location: Prudnik, Poland

Re: STM32L0 - how to check available RAM memory

Post by GonzoG »

dannyf
Posts: 446
Joined: Sat Jul 04, 2020 7:46 pm

Re: STM32L0 - how to check available RAM memory

Post by dannyf »

Unique ID, if the chip supports it.
User avatar
Bakisha
Posts: 139
Joined: Fri Dec 20, 2019 6:50 pm
Answers: 5
Contact:

Re: STM32L0 - how to check available RAM memory

Post by Bakisha »

I once found same thing in SdFat library, called "FreeStack.h"

From that, simple sketch should work (at least at STM32F1/4):

Code: Select all

//  from SDfat library
extern "C" char* sbrk(int incr);
// free RAM (actually, free stack
inline uint32_t FreeBytes() {
  char top = 't';
  return &top - reinterpret_cast<char*>(sbrk(0));
}
void setup() {
    Serial.begin(115200);
  delay(2000);
}
void loop() {
  Serial.println(FreeBytes());
  delay(1000);
}
Maybe not 100% accurate, but it was enough for my case.
Post Reply

Return to “General discussion”