Author Topic: stm32 flash memory or sram  (Read 1710 times)

0 Members and 1 Guest are viewing this topic.

Offline jealcunaTopic starter

  • Contributor
  • Posts: 39
  • Country: ec
stm32 flash memory or sram
« 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.
 

Offline andersm

  • Super Contributor
  • ***
  • Posts: 1198
  • Country: fi
Re: stm32 flash memory or sram
« Reply #1 on: July 19, 2019, 06:11:53 pm »
Just use a statically allocated array.
 
The following users thanked this post: jealcuna

Offline Kjelt

  • Super Contributor
  • ***
  • Posts: 6460
  • Country: nl
Re: stm32 flash memory or sram
« Reply #2 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.
« Last Edit: July 19, 2019, 06:26:48 pm by Kjelt »
 
The following users thanked this post: jealcuna

Offline jealcunaTopic starter

  • Contributor
  • Posts: 39
  • Country: ec
Re: stm32 flash memory or sram
« Reply #3 on: July 19, 2019, 09:33:49 pm »
You say,

Code: [Select]
static uint8_t signals[3600];  ?
 

Offline thm_w

  • Super Contributor
  • ***
  • Posts: 6349
  • Country: ca
  • Non-expert
Re: stm32 flash memory or sram
« Reply #4 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.
Profile -> Modify profile -> Look and Layout ->  Don't show users' signatures
 
The following users thanked this post: jealcuna

Offline andersm

  • Super Contributor
  • ***
  • Posts: 1198
  • Country: fi
Re: stm32 flash memory or sram
« Reply #5 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.
 
The following users thanked this post: jealcuna


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf