STM32F411CEU6 Backup Registers and SRAM

Post here all questions related to STM32 core if you can't find a relevant section!
Post Reply
RedSky1
Posts: 2
Joined: Sun Jul 26, 2020 12:00 pm
Answers: 1

STM32F411CEU6 Backup Registers and SRAM

Post by RedSky1 »

Hi All,

First time poster and a bit of a rookie on STM32 and Arduino coding. I'm currently using the 1.9.0 Core and a STM32F411CEU6 based 'black pill'
and trying to use the 4KB SRAM these chips have to store variables in the backup battery backed memory.
I have a 3v lithium battery, positive on the VBAT pin and negative to ground and connecting the Black Pill using a 232 FTDI serial dongle, standard stuff.

Not a lot of information around on using this, The functions reference I found to write up some test code was in the Core backup.h source file to use enableBackupDomain() to enable the chip features and readBackupSRAM and writeBackupSRAM to read and write from SRAM.
The memory location (BKPSRAM_BASE) I found on a Google search for STM32F4 backup SRAM location but couldn't find this information in the datasheet.

The below code is what I have come up with to test out the RTC registers & SRAM functionality. The RTC register part works perfectly however the bit I am stuck on is specifically the SRAM part, I can get nothing but 0's back shown on the serial monitor no matter what I do or try.

If anyone has an ideas or has managed to get this working I would appreciate the feedback, I could be way off on the proper use of these functions.

Code: Select all

uint32_t WriteRegisterValue = 123456;
uint32_t ReadRegisterValue;
uint32_t WriteSRAMValue[10];
uint32_t ReadSRAMValue[10];

uint32_t BKPSRAM_BASE=0x40024000;

void setup() {
  Serial.begin(115200);
  delay (1000);

  enableBackupDomain(); 
}

void loop() {

  //Store number in RTC Backup Registers
  setBackupRegister(1, WriteRegisterValue);
  
  //Store numbers in RTC SRAM
  WriteSRAMValue[1]=244;
  WriteSRAMValue[2]=344;
  writeBackupSRAM(1, WriteSRAMValue, 2);
  
  delay(2000);
  
  //Retrieve number in RTC Backup Registers
  ReadRegisterValue = getBackupRegister(1);
  Serial.println(ReadRegisterValue);
  
  //Retrieve numbers in RTC SRAM
  readBackupSRAM(1, ReadSRAMValue, 2);
  Serial.println(ReadSRAMValue[1]);
  Serial.println(ReadSRAMValue[2]);
  
  delay(2000);
}
by RedSky1 » Mon Jul 27, 2020 4:21 am
Well turns out I answered my own question...

Why could I not easily find the memory address and could not get this SRAM stuff to work on the STM32F411? Because it does not have the 4KB SRAM on this variant!

The STM32F407/415 does, as does a number of others, the STM32F411 & STM32F401 in the common 'Black Pills' does not.

Looks like i'll need to make do with 80 bytes of RTC register memory as the flash writes in Emulated EEPROM are amazingly slow due to the need to clear the flash before each write.

That's a lesson for me, study the differences between chips in the same family more next time. I'll leave this here in the hope it may save someone else some time :)
Go to full post
RedSky1
Posts: 2
Joined: Sun Jul 26, 2020 12:00 pm
Answers: 1

Re: STM32F411CEU6 Backup Registers and SRAM

Post by RedSky1 »

Well turns out I answered my own question...

Why could I not easily find the memory address and could not get this SRAM stuff to work on the STM32F411? Because it does not have the 4KB SRAM on this variant!

The STM32F407/415 does, as does a number of others, the STM32F411 & STM32F401 in the common 'Black Pills' does not.

Looks like i'll need to make do with 80 bytes of RTC register memory as the flash writes in Emulated EEPROM are amazingly slow due to the need to clear the flash before each write.

That's a lesson for me, study the differences between chips in the same family more next time. I'll leave this here in the hope it may save someone else some time :)
Aakriti
Posts: 1
Joined: Mon Oct 09, 2023 4:56 pm

Re: STM32F411CEU6 Backup Registers and SRAM

Post by Aakriti »

Hi all
Exploring STM32F411CEU6's Backup Registers and SRAM is crucial for data retention and real-time clock functionality in embedded systems.GB whatsapp Apk
Post Reply

Return to “General discussion”