Some F103C8 have 64 KB Flash. For these MCUs, the flash address is valid between 0x08000000 to 0x08010000. Make sure you check if you have the 64KB or 128 KB flash. You can check it in the cubeIDE at the bottom right ( in memory usage window) or check the flash.ld script file.
Great tutorial! But we just need to remember everyone to DO NOT use your flash to store non constant data . STM32F1 series guarantee only 1k Cycles, which of course the real number is around 10k Cycles. But you can burn your flash easily if you use this as RAM.
.. its depend on the use case. I'm sure that anyone who write to flash will know the limitations and will see it's more complicated than dealing with RAM. The flash should last for at least 10k Cycles, according to the datasheet.
Hello sir I regularly watch your video and try to learn and where I stuck i put a quarry in comment and you always help to clear that thanks you so much ❤️❤️
In function void Flash_Read_Data (uint32_t StartPageAddress, uint32_t *RxBuf, uint16_t numberofwords){....} must be if (!(--numberofwords)) break; not if (!(numberofwords--)) break; It's two big differences. It's two different cases.
I just wrote an application where I wanted to save a calibration value to flash and, of course, turned to RU-vid. All I could find was code and libraries that didn't work with the STM32F103C8T6. Made some changes, and thought I found an error in the standard library. Turns out I was trying to use FLASH_PageErase that didn't clear the FLASH_CR_PER bit, so when I went to write to flash, the PageERase bit was still set, so wouldn't write. Thanks for the great library!!! A week earlier would have saved me many hours and the embarrassment of submitting an error report to STM. (However, I still believe that CLEAR_BIT(FLASH->CR, FLASH_CR_PER); belongs in the same procedure as the SET_BIT.)
I was lucky to stumble upon your video. It worked flawlessly. I was working on the ST eeprom emulation that didn't work at all with many errors popping up from their sample code. I'm not sure how you managed to figure all this out. I'm curious to know how you managed to get it done alone. I'm interested in knowing how to solve such problems on my own. Their documentation is all over the place and not consolidated in an understandable manner. Any feedback would be appreciated.
Hmm i did some research with the sample codes. Saw the reference manual, saw some similarities in the m3 and m4 series codes. Did some experiments with the random memory locations..
@@ControllersTech Thanks, it seems to be the standard way we should all know by familiarizing ourselves with ST way of thinking. Currently working on STM32F103C8 because it is widely available. The reference manual feels minimal on documentation as there are many things I had to discover from the internet rather than direct reference to the manual itself. One man doing everything for a single project is not easy. Too much to consider. Not sure if I will ever finish my product. Life catches up to you when you least suspect it. Thank you for everything. Your videos are simple to understand and replicate on the bench. Your remarkable work accelerate learning by removing doubts about certain aspect of this technology. I can't thank you enough, but nonetheless, thank you again.
Amazing tutorial. I am using STM32G474RE, which is M4, but according to the manual it has 2 banks with 128 pages each. In the manual it says "It is only possible to program double word (2 x 32-bit data).". How should I change the code in order to work when I am trying to write 2 different variables, each uint32. Thank you
@@yogaline8218 I concatenated the 2 variables into one 64-bit, and then wrote it in Flash. Here is the code that I used: Flash_Tx = ((uint64_t)VarA*1000000000) + VarB; Writeaddress=Flash_Write_Data(Writeaddress, &Flash_Tx, 2); And here is my Flash_Write_Data function: uint32_t Flash_Write_Data (uint32_t StartPageAddress, uint64_t *Data, uint16_t numberofwords) { int sofar=0; /* Unlock the Flash to enable the flash control register access *************/ HAL_FLASH_Unlock(); /* Program the user Flash area word by word*/ while (sofar
Hello Sir, We could write once and we are anot able to erase and update the last page. It looks like the flash is write protected. I meant we can compile and flash the chip. but we are not able erase the last page in our application software. How do we know the flash is write protected and How to clear the write protect before page erase? Could you please help us out?
Hi @Controllerstech! Thanks to you bro. I have improved tech knowledge of stm32 through your channel. That's all credits goes to you. But bro I am stuck in a problem last 3 days. Can you help me out in it? I am working on STM32L4+ controller and playing with USB CDC between STM32 and ESP32. Problem:- I have to write c code to check whether stm32 memory full or not. Do you have any reference program ?
Hello, i'm trying to make save and load data, let's say i'm just inputting value "100" to be saved, but when i load the data, it got messed up, the output isn't same with then input when the data is read, so any solutions?
Need Help in storing Audio files (MP3,AMR,WAV) in 16MB flash memory and play using ESP32 wroom 32D, which software and programmer Do I need to use to store Audio files on W25Q64FV or similar winbond flash memory ? I am currently using Arduino IDE, I can detect SPI chip ID,using Basic arduino SPI flash code,Please Help.
If using FLASH page(s) for user data, should you modify the linker scripts to ensure that the compiler reserves it as to not place executable code there? Also, on the Dual-Core devices (ex. STM32H7), where there are TWO 8-sector Banks (0x8000000-0x80FFFFF & 0x8100000-0x81FFFFF), how do both CPUs share/execute from this? For example, could one sector be used for the M4, and 15 sectors used for the M7? Could they execute from the same sector? For example, it seems they have the same reset vector address (0x00000000)!
Sorry for interrupt you [my english not good] Could you please teach me , I need to copy program of STM32030CC from other broad to my broad. How to i do it ?
In my uC, erase memory not work, only write the flash memory one time. If i want write again, not work, y read the first value, after I erase all chip memory whit stm32CubeProgrammer. I use the same board like you. I replace strlen with sizeof and not work. Can you help, please?
@@ControllersTech Work fine with a 128 kb bluepil, with 64kb version, not work. I buy 20 bluepil, all 64kb, when i bought them i didn't know. :-(. Can anything be done with the 64kb version?
Sir I try to write multiple float value. When I write values on different pages then it work but when I write on same page example int num1=20; int num2=30; int num3=40 Flash_Write_NUM(0x0800FC00, num1); Flash_Write_NUM(0x0800FC04, num2); Flash_Write_NUM(0x0800FC08, num3); only last value is written on memory address ,how to clear this problem.
Try to write data in single operation. Before every write, the entire sector/page is erased. Better modify your data and then write it in single operation
how can we observe the servo motor motion coming from the simulaiton like simtools ? It is basicly simtools create a data ( like game datas ) and stm32f should read this and after that from this data servo motor should move according the simtools data. How can we do that ?? Please make a video about simtools stm32f and servo motors....! There is no any video about it... content: simtools create a data and stm32f read this. After that servo motors move... There is no video about it if you do this you are the first person on the earth......
is it wise to store the counter value in the flash memory so that a counter value can be stored permanently and the next day it can be started from the previous counter value or EEPROM should be used? As counter value store 100000 times one by one in flash memory in a day.
Hi, I tried the code on the Blue Pill with 64k of Flash. For my code it is not working as it should. If I write the same hex numbers as shown in the video they are written - no problem in the flash. But when try to use it in my code - only the first number in the array is stored! What do you think is the problem? (PS: what i try to store is integer numbers like 1000, 1 etc.)
I need to see the code to comment on it. Anyway, you can check yourself what value is being passed to the flash_write function and what it is actually writing
github.com/controllerstech/STM32/blob/master/EEPROM_STM32/EEPROM.c Check the functions float2byte and byte2float. It's for the eeprom but the method would be similar in flash also.
Hi.. Great tutorial maan..i have one doubt. I just have one data to store.I will have to write that data to same address every five minutes.and every time the board resets i want to read the data.So in that thing..do i need to erase the page every time i writes..or will it over write the data in the address?
@@ControllersTech There are no questions about it , you are a well knowledge person in this field Please explain me more about eclipse marketplace how to use it, up the point to change the background screen (dark theme ) as in this video. Or there are steps to follow on the CUBEIDE main screen only. Thanks
I ve stored data in 0801fc00, then after that I've to store another data in 0801fc04 but after pressing reset button all the value where I stored in 0801fc00 & 0801fc04 get vanished
So to store a float, which is 4 bytes, it is up to us to convert the float to its integer representation first before storing? Asking because I always try to first code what you show myself then look at how you do it. I see that you did not store any floats. Keep up the great work.
No.. you can store the float as it is. I don't recall doing any such thing in this video. Anyway, if u want to print float or an integer on any display, or send them via the uart, then u need to convert them to characters.
@@ControllersTech I had to do a union to get the uint32_t representation of a float so it can be stored. Try to store a float in flash and you will see what I mean.
@@ControllersTech I did. There is no explanation. In case you weren't watching what you were doing you chose the part C8tx. A 64k device. Pages 127 and 128 shouldn't exist
Yes i am using bluepill in this video. The pages do exist.. how else will it write to that location? Like i said in another comment, some f103c8 have 64 bytes and others have 128 bytes. How and why ST doing it ? Well I don't know about that.. Check the picture of my bluepill memory details below controllerstech.com/wp-content/uploads/2021/02/f103memory.jpg
int numberofwords = (strlen(DATA_32)/4) + ((strlen(DATA_32) % 4) != 0); When I run the code in Keil v5, it considers the above mentioned line as error and not as warning. Could you pls help me out with this?
I'm using Keil IDE and it shows errors ''#error 167: argument of type uint32_t is incompatible with parameter of type const char *", do you know any solution?
You can typecast to 32 bit an use.. Or look inside the flash write function, where the main write takes place. I have commented out the hint for bytes and half words
I hope someone can help me. It works for me but when I try multiple memory cells only one is stored. Is it not allowed to write to e.g. FC00 and F800 at the same time?
@@ControllersTechIn "0x0801 FC00" and in "0x0801 F400" works. But when I try to write in "0x0801 FC00" and "0x0801 F800" it doesn't work. Maybe you have a better solution for my task? I have 8 values. They are all int values from 0 to 30000. I thought I would save each value in a memory cell. Is this a good idea? My actual approach looks like this. #include "FLASH_PAGE.h" uint32_t data_ONE[1] = { }; uint32_t data_TWO[1] = { }; __IO uint32_t reed_ONE[1]; __IO uint32_t reed_TWO[1]; int main(void) { Flash_Read_Data(0x0801F400, reed_ONE); Flash_Read_Data(0x0801FC00, reed_TWO); while (1) { if (buttun_Pusch) { data_ONE[0] = (uint32_t) variable_1; // variable 0 to 30000 data_TWO[0] = (uint32_t) variable_2; // variable 0 to 30000 Flash_Write_Data(0x0801F400, data_ONE); Flash_Write_Data(0x0801FC00, data_TWO); } } }
Just create an array of the values, and then use flash write and pass the array You also might need to modify the function a little. Instead of calculating the numberofwords, just pass the number of words in the function parameter.
@@ControllersTech Yes it is mentioned as a pages. But each page its size is 4kb. But in your video it is mentioned for 1kb. Is this support for my features?. The flash memory for my board is 1 Mb