This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello,
I am working on a project and I saw that I can store my code in FLASH memory.
I am not that good with processor architecture and I need a few explanations about FLASH:
1.) If I store the code in FLASH memory, will my arrays and data still be saved in RAM memory, only code is stored in FLASH? (That way I get more space because my code itself will not use any RAM space?)
2.) Why is code running slower if i store it in FLASH?
3.) For my project I need to do ADC at about 850kHz (I am adding every 32 together for oversampling). Will running code from FLASH affect the processor so I might not be able to do ADC so fast?
Thank you very much for the answer, it will mean a lot to me.
Best regards,
Ivan.
Hi Ivan,
1.) If I store the code in FLASH memory, will my arrays and data still be saved in RAM memory, only code is stored in FLASH? (That way I get more space because my code itself will not use any RAM space?)
It depends on where different section of code placed in linker cmd file.
2.) Why is code running slower if i store it in FLASH?
How much difference you are seeing? FLASH is wait stated memory (different wait state based on CPU frq) so it'll be slow but we have pre-fetch which need to be enabled to minimize the impact. Please check the example code running from flash for these setting.
3.) For my project I need to do ADC at about 850kHz (I am adding every 32 together for oversampling). Will running code from FLASH affect the processor so I might not be able to do ADC so fast?
Even though you are programming the code in flash, you can always copy time critical code in RAM from flash during run time and then execute it from RAM. Basically have LOAD in FLASH but RUN from RAM option. You can get this info also from example code which copies the FLASH configuration code to RAM.
Regards,
Vivek Singh
Hi,
thanks for quick answer!
So I can put some parts of my code in FLASH and some in RAM? That will solve my problems.
Thanks,
Ivan.