HI Everyone
The board I use is STM32L475RCT6
I've tried three different libraries and official sample programs
But no matter which kind, the compilation is normal,it will crash directly when executed
1. https://github.com/khoih-prog/FlashStor ... EEPROM.ino
2.https://github.com/S-LABc/using-interna ... eeprom.ino
3.https://github.com/stm32duino/STM32Exam ... EEPROM.ino
Below is the function of the EEPROM I wrote using the UNO and ESP32, I don't know how to modify it to make it work on the L475
Hope someone can tell me what's wrong
#include <EEPROM.h>
String cmd;
String ID;
// define the number of bytes you want to access
#define EEPROM_SIZE 4096
void setup() {
Serial.begin(115200);
// initialize EEPROM with predefined size
EEPROM.begin(EEPROM_SIZE);
}
////
void writeStringToEEPROM(int addrOffset, const String &strToWrite)
{
byte len = strToWrite.length();
EEPROM.write(addrOffset, len);
for (int i = 0; i < len; i++)
{
EEPROM.write(addrOffset + 1 + i, strToWrite);
}
}
String readStringFromEEPROM(int addrOffset)
{
int newStrLen = EEPROM.read(addrOffset);
char data[newStrLen + 1];
for (int i = 0; i < newStrLen; i++)
{
data = EEPROM.read(addrOffset + 1 + i);
}
data[newStrLen] = '\0';
return String(data);
}
////
void loop() {
if (Serial.available()) {
String s = "";
while (Serial.available()) {
char c = Serial.read();
if(c!='\n'){
s += c;
}
delay(5);
}
if(s!=""){
cmd =s;
//Serial.println(cmd);
if(cmd.substring(0,3)=="ID=")
{
ID = cmd.substring(3,6);
Serial.println(ID);
//EEPROM.write(0,ID);
writeStringToEEPROM(0,ID);
EEPROM.commit();
Serial.println("OK");
delay(100);
}
else if(cmd=="ID?\r")
{
String retrievedString = readStringFromEEPROM(0);
Serial.println(retrievedString);
delay(100);
}
else if(cmd=="help\r")
{
Serial.println("ID?");
Serial.println("ID=");
}
else{}
}
}//if (Serial.available())
}//loop
Using STM32L475RCT to implement EEPROM crashes
Post here first, or if you can't find a relevant section!
-
- Posts: 1
- Joined: Sat Jun 11, 2022 7:43 pm
Return to “General discussion”
Jump to
- Announcements
- New users start here
- ↳ Forum rules, FAQs and HowTo's
- ↳ Let us know a bit about you and your projects
- Arduino for STM32
- ↳ General discussion
- ↳ Ideas & suggestions
- ↳ Cores
- ↳ STM32 Core
- ↳ Builds and Announcements
- ↳ Code snippets
- ↳ Ideas & suggestions
- ↳ General discussion
- ↳ Installation and OS related
- ↳ Libraries & Hardware
- ↳ PR's bugs and enhancements
- ↳ LibMaple
- ↳ Builds and Announcements
- ↳ Code snippets
- ↳ General discussion
- ↳ Ideas & suggestions
- ↳ Installation and OS related
- ↳ Libraries & Hardware
- ↳ PR's bugs and enhancements
- ↳ Steve's LibMaple core
- ↳ General discussion
- ↳ PR's bugs and enhancements
- ↳ Projects
- ↳ IDE's
- ↳ Off topic
- Arduino for STM8
- ↳ General discussion
- ↳ Cores
- ↳ STM8 Core
- ↳ Other
- Boards
- ↳ Custom design boards
- ↳ Maple & Maple mini etc
- ↳ STM boards (Discovery, Eval, Nucleo, ...)
- ↳ All other boards
- ↳ STM32F0 based boards
- ↳ STM32F1 based boards
- ↳ STM32F2 based boards
- ↳ STM32F3 based boards
- ↳ STM32F4 based boards
- ↳ STM32F7 based boards
- ↳ STM32G0 based boards
- ↳ STM32G4 based boards
- ↳ STM32H7 based boards
- ↳ STM32L0 based boards
- ↳ STM32L1 based boards
- ↳ STM32L4 based boards
- ↳ STM32L5 based boards
- ↳ STM32MP1 based boards
- ↳ STM32WB based boards
- Bootloaders
- ↳ STM32 HID bootloader
- ↳ USB bootloader
- ↳ STM32 SD-Bootloader
- ↳ STM32 USB CDC bootloader
- Uploaders and debuggers
- ↳ STLink
- ↳ USB to Serial adaptors
- ↳ Black Magic Probe & other
- Dead Thread Graveyard
- ↳ Dead Thread Graveyard