2025-06-30 10:42 PM - last edited on 2025-07-01 1:54 AM by Andrew Neil
Post edited to follow the ST community rules. Please use </> button to paste your code. See this post.
Hello All
I'm working on an load cell based solution using ADS1232 as AFE. Due to the constraints, we have not used external EEPROM.
IDE- Arduino IDE - 2.3.2
Library used - https://github.com/khoih-prog/FlashStorage_STM32
EVB - Nucleo-G0B1RE
Target Device - STM32G0B1RC
ISSUE- ON EVB, I'm able to read, store, fetch and modify the flash content.. however, same code is not working for target board.
Attachment - Target Board Logs
Attachment - EVB Board Logs
Attachment - Arduino settings
//-------CODE----
#include <FlashStorage_STM32.h>
#define STR_SW PD_2 // Button pin
#define DIG_SW PD_3 // UP
const int WRITTEN_SIGNATURE = 0xBEEFDEED;
HardwareSerial RS232Serial(PB_9, PB_8); // UART3 TX, RX
volatile bool buttonPressed = false;
// EEPROM base address
#define ADDR_SIGNATURE 0
#define ADDR_COUNTERS 8 // Leave space for signature
struct CounterData {
int count1;
int count2;
int count3;
};
CounterData counters = {0, 0, 0};
void handleButtonISR() {
buttonPressed = true;
}
void setup() {
RS232Serial.begin(115200);
while (!RS232Serial);
delay(200);
// eeprom_clr();
RS232Serial.println("\n--- Start EmulatedEEPROM with Struct ---");
RS232Serial.println(FLASH_STORAGE_STM32_VERSION);
RS232Serial.println();
pinMode(STR_SW, INPUT_PULLUP);
pinMode(DIG_SW, INPUT);
attachInterrupt(digitalPinToInterrupt(STR_SW), handleButtonISR, RISING);
RS232Serial.print("Emulated EEPROM length (bytes) = ");
RS232Serial.println(EEPROM.length());
RS232Serial.println();
int signature = 0;
EEPROM.get(ADDR_SIGNATURE, signature);
if (signature != WRITTEN_SIGNATURE) {
RS232Serial.println("EEPROM uninitialized. Writing defaults...");
counters = {0, 0, 0};
EEPROM.put(ADDR_SIGNATURE, WRITTEN_SIGNATURE);
EEPROM.put(ADDR_COUNTERS, counters);
EEPROM.commit();
RS232Serial.println("Default values committed.");
} else {
EEPROM.get(ADDR_COUNTERS, counters);
RS232Serial.println("EEPROM valid. Reading previous values...");
}
RS232Serial.print("Stored Value Count1: "); RS232Serial.println(counters.count1);
RS232Serial.print("Stored Value Count2: "); RS232Serial.println(counters.count2);
RS232Serial.print("Stored Value Count3: "); RS232Serial.println(counters.count3);
}
void loop() {
static uint32_t loopCount = 0;
static uint32_t lastDebounce = 0;
if (digitalRead(DIG_SW) == LOW && millis() - lastDebounce > 150) {
lastDebounce = millis();
counters.count1++;
counters.count2 += 2;
counters.count3 += 3;
RS232Serial.println("Button Press Detected. Counters Updated:");
RS232Serial.print("Count1: "); RS232Serial.println(counters.count1);
RS232Serial.print("Count2: "); RS232Serial.println(counters.count2);
RS232Serial.print("Count3: "); RS232Serial.println(counters.count3);
}
if (buttonPressed) {
buttonPressed = false;
RS232Serial.println("Commit Press Detected. Counters Stored:");
EEPROM.put(ADDR_COUNTERS, counters);
EEPROM.commit();
RS232Serial.print("Committed Value Count1: "); RS232Serial.println(counters.count1);
RS232Serial.print("Committed Value Count2: "); RS232Serial.println(counters.count2);
RS232Serial.print("Committed Value Count3: "); RS232Serial.println(counters.count3);
}
if (++loopCount % 50 == 0) {
RS232Serial.println("Loop running...");
}
delay(10);
}
2025-07-01 1:35 AM
Hello @Mayank_K
This is an Arduino code and should be shared on the Arduino platform.
2025-07-01 1:50 AM
Hello @Mayank_K and welcome to the ST community,
As said by @Saket_Om no much support for Arduino IDE here. Please ask your question in their forum: https://www.stm32duino.com/
Thank you
2025-07-01 1:53 AM
@Mayank_K wrote:IDE- Arduino IDE - 2.3.2
Library used - https://github.com/khoih-prog/FlashStorage_STM32
So, presumably, using STM32Duino?
As @Saket_Om said, STM32Duino questions should go here: https://www.stm32duino.com/
Or in the general Arduino forums: https://forum.arduino.cc/
Did you see the Troubleshooting tips for the library? Also how to raise support issues with it:
https://github.com/khoih-prog/FlashStorage_STM32?tab=readme-ov-file#troubleshooting