STM32F103C8T6 problem with EEPPROM..

Post here all questions related to LibMaple core if you can't find a relevant section!
iz7jxj
Posts: 10
Joined: Sat Aug 21, 2021 1:58 pm

Re: STM32F103C8T6 problem with EEPPROM..

Post by iz7jxj »

.rpv wrote: Sun Aug 22, 2021 11:59 pm Ok, first, in my experience using unsigned long it's problematic if you don't specify literally on each mention/operation

Something like this should work:

Code: Select all

unsigned long x=1000000;

setup(){
//...//
Serial.print(x);
}
But I'll expect funny things on this:

Code: Select all

unsigned long x;

setup(){
//...//
x=1000000;
Serial.print(x);
}

Code: Select all

unsigned long x=1000000;

setup(){
//...//
x=x*5;
Serial.print(x);
}
For the previous I'll use:

Code: Select all

unsigned long x;

setup(){
//...//
x=(unsigned long)1000000;
Serial.print(x);
}

Code: Select all

unsigned long x=1000000;

setup(){
//...//
x=x*(unsigned long)5;
Serial.print(x);
}
On the eeprom problems, you seems to use ST core, but I didn't see any errors.
The EEPROM.read/EEPROM.write are just for single byte read/write, but using stcore you can use instead:

https://www.arduino.cc/en/Reference/EEPROMGet
https://www.arduino.cc/en/Reference/EEPROMPut

also, for the address you're giving (0x10) 10000 address, the flash eeprom it's just something like 1k-2k, so you should do something like:

EEPROM.get(0,iftrans);
and/or
EEPROM.put(0,iftrans);

Hi ...
Loaded the library "" FlashStorage_STM32F1 ""
but it is NOT compatible with my blue pill card.
How is it possible ???
my BLUE PILL bootloader was loaded with
"" "https://github.com/stm32duino/BoardMana ... index.json" ""
this would be fair. ????
Honestly I DON'T know what to try anymore ..! :oops:

.rpv thank you for your time dedicated to me ... !!!!
Attachments
Clipboard01.jpg
Clipboard01.jpg (94.01 KiB) Viewed 2833 times
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: STM32F103C8T6 problem with EEPPROM..

Post by ag123 »

ok first of all, u'd need to figure out if you are using 'libmaple' (aka "roger's" core) or stm32duino (official) core.

normally these are the faqs that one need to get familiar with while getting started
viewtopic.php?f=2&t=3
viewtopic.php?f=2&t=301

there is a chance that you may be running the libmaple core.

try this code

Code: Select all

void setup() {
	Serial.begin();
	while(!Serial);
}

void loop() {
#ifdef ARDUINO_ARCH_STM32
	Serial.println("stm32duino core");
#elif defined(ARDUINO_ARCH_STM32F1)
	Serial.println("libmaple core");
#elif defined(ARDUINO_ARCH_STM32F4)
	Serial.println("libmaple f4 core");
#else
	Serial.println("unknown core");
#endif
	delay(1000);
}
on another note, 'libraries' are just c++ codes, so an easy way is to just copy the libraries codes .cpp and .h into the sketch folder, change the include paths and rebuild
iz7jxj
Posts: 10
Joined: Sat Aug 21, 2021 1:58 pm

Re: STM32F103C8T6 problem with EEPPROM..

Post by iz7jxj »

ag123 wrote: Mon Aug 23, 2021 8:49 pm ok first of all, u'd need to figure out if you are using 'libmaple' (aka "roger's" core) or stm32duino (official) core.

normally these are the faqs that one need to get familiar with while getting started
viewtopic.php?f=2&t=3
viewtopic.php?f=2&t=301

there is a chance that you may be running the libmaple core.

try this code

Code: Select all

void setup() {
	Serial.begin();
	while(!Serial);
}

void loop() {
#ifdef ARDUINO_ARCH_STM32
	Serial.println("stm32duino core");
#elif defined(ARDUINO_ARCH_STM32F1)
	Serial.println("libmaple core");
#elif defined(ARDUINO_ARCH_STM32F4)
	Serial.println("libmaple f4 core");
#else
	Serial.println("unknown core");
#endif
	delay(1000);
}
on another note, 'libraries' are just c++ codes, so an easy way is to just copy the libraries codes .cpp and .h into the sketch folder, change the include paths and rebuild

Hi ag123 ..!

I did what you told me and this is the result. ""LIBMAPLE CORE""
Seeing this result, you can give me a SIMPLE example of writing and reading an UNSIGNED LONG variable on an EEPROM address
valid for this BLUE PILL ... ???

THANK YOU VERY MUCH..!!
Attachments
Clipboard01.jpg
Clipboard01.jpg (93.51 KiB) Viewed 2773 times
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: STM32F103C8T6 problem with EEPPROM..

Post by ag123 »

well you are on your own here, as i've not tried messing with that (yet)

if your needs are rather modest, there are some backup registers.
read RM0008 chapter 6 backup registers (BKP)
and review the datasheet for the same
https://www.st.com/resource/en/datashee ... f103c8.pdf
2.3.14 RTC (real-time clock) and backup registers
The RTC and the backup registers are supplied through a switch that takes power either on
VDD supply when present or through the VBAT pin. The backup registers are ten 16-bit
registers used to store 20 bytes of user application data when VDD power is not present.
the thing is you need to power up the VBAT pin (say with a coin cell) if you want to do that, VBAT is used for the RTC). or data is lost when power VDD is lost.
the commands goes something like (note this is libmaple specific, no other cores in the world does this)

Code: Select all

void setup() {
	Serial.begin();
	bkp_init();
}

void loop() {
	uint8_t reg = 1;
	uint16_t val = 1000; 

	bkp_enable_writes();
	bkp_write( reg, val);
	bkp_disable_writes();
	
	uint16_t val_read = bkp_read(reg);
	Serial.println(val_read);
	delay(1000);
}
the api for that is here
https://github.com/rogerclarkmelbourne/ ... e/bkp_f1.c
https://github.com/rogerclarkmelbourne/ ... aple/bkp.h

there is an EEPROM library shipped with the core.
these libraries are normally caveat emptor 'let the buyer beware' - it may not work. but it may u'd need to work the codes & try it out
https://github.com/rogerclarkmelbourne/ ... ies/EEPROM

otherwise use the official stm32duino core and there is a eeprom library for it there
https://github.com/stm32duino/Arduino_C ... ies/EEPROM

these eeprom libraries use part of the on-chip flash to store that data.
iz7jxj
Posts: 10
Joined: Sat Aug 21, 2021 1:58 pm

Re: STM32F103C8T6 problem with EEPPROM..

Post by iz7jxj »

ag123 wrote: Tue Aug 24, 2021 9:33 am well you are on your own here, as i've not tried messing with that (yet)

if your needs are rather modest, there are some backup registers.
read RM0008 chapter 6 backup registers (BKP)
and review the datasheet for the same
https://www.st.com/resource/en/datashee ... f103c8.pdf
2.3.14 RTC (real-time clock) and backup registers
The RTC and the backup registers are supplied through a switch that takes power either on
VDD supply when present or through the VBAT pin. The backup registers are ten 16-bit
registers used to store 20 bytes of user application data when VDD power is not present.
the thing is you need to power up the VBAT pin (say with a coin cell) if you want to do that, VBAT is used for the RTC). or data is lost when power VDD is lost.
the commands goes something like (note this is libmaple specific, no other cores in the world does this)

Code: Select all

void setup() {
	Serial.begin();
	bkp_init();
}

void loop() {
	uint8_t reg = 1;
	uint16_t val = 1000; 

	bkp_enable_writes();
	bkp_write( reg, val);
	bkp_disable_writes();
	
	uint16_t val_read = bkp_read(reg);
	Serial.println(val_read);
	delay(1000);
}
the api for that is here
https://github.com/rogerclarkmelbourne/ ... e/bkp_f1.c
https://github.com/rogerclarkmelbourne/ ... aple/bkp.h

there is an EEPROM library shipped with the core.
these libraries are normally caveat emptor 'let the buyer beware' - it may not work. but it may u'd need to work the codes & try it out
https://github.com/rogerclarkmelbourne/ ... ies/EEPROM

otherwise use the official stm32duino core and there is a eeprom library for it there
https://github.com/stm32duino/Arduino_C ... ies/EEPROM

these eeprom libraries use part of the on-chip flash to store that data.

I really appreciate your recommendations but for the moment I am not up to it ... !! I just started.
slowly ... slowly I will learn.
I just wanted to see an example of writing and reading the emulated eeprom of a value of a variable.
thanks anyway for your interest ... !!
Saluti...!!!!
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: STM32F103C8T6 problem with EEPPROM..

Post by ag123 »

if you want to use the FlashStorage (FlashStorage_STM32F1 Library) Library, khoih-prog posted it here:
viewtopic.php?f=39&t=1218

you'd need to use the official stm32duino core with it
Post Reply

Return to “General discussion”