EEVblog Electronics Community Forum

Electronics => Microcontrollers => Topic started by: jealcuna on July 19, 2019, 06:07:19 pm

Title: stm32 flash memory or sram
Post by: jealcuna on July 19, 2019, 06:07:19 pm
I am downsamplign a signal to 1 sample per second during 1 hour as maximum and using 1 byte per sample. I want  to stoarge this signal but I am not sure if by using sram memory of STM32F446 (128KB) will be enough. Also I am thinking in the posibility to keep at least 20 signal and again with 1 hour as maximun with 1 sample per second and 1 byte per sample. This give the followinng results:

* 3600 seconds x 1 byte x 1 sample/second = 3600 bytes per signal
* for 20 signals -> 20 x 3600 bytes = 72000 bytes

I am not sure if my assumption is ok, but I have 128Kb for sram and also it is divided in stack, heap and Data. I dont know how to proceed. I know that I can reserve memory for data by using malloc or calloc. But It is not clear for me how to configure the start file .s to achieve this.

Also memory flash is a candidate but I will prefer read your opinions.
Title: Re: stm32 flash memory or sram
Post by: andersm on July 19, 2019, 06:11:53 pm
Just use a statically allocated array.
Title: Re: stm32 flash memory or sram
Post by: Kjelt on July 19, 2019, 06:25:17 pm
Use a statically assigned double medium sized sram buffer in combination with a large external flash prom spi or i2c.
Write first buffer till full set flag switch to second buffer and write the contents of the first buffer to the external flash memory (verify written data) then delete first buffer.
When second buffer full , switch to first buffer for storing and save the second to ext flash, etc etc.

Make sure the size of your sram buffer is aligned with the flash page size, so for instance if your flash page size is 2kB choose 2kB or 4kB or 6kB etc.
Title: Re: stm32 flash memory or sram
Post by: jealcuna on July 19, 2019, 09:33:49 pm
You say,

Code: [Select]
static uint8_t signals[3600];  ?
Title: Re: stm32 flash memory or sram
Post by: thm_w on July 19, 2019, 10:37:01 pm
They mean statically allocated as in the size does not shrink or grow.
so uint8_t signals[20][3600] or signal[3600] yes.
Title: Re: stm32 flash memory or sram
Post by: andersm on July 19, 2019, 11:11:11 pm
Also static as in storage duration, so either a global variable or static local variable, whatever suits your code. The point is that you want the space to be allocated at compile time.