Reputation:
I am currently programming a microcontroller. The RAM size is 4kb. What it should do: It should sleep for 10 minutes, wake up, measure the temperature, store this temperature and then go to sleep again. This should be done in a 10 minute interval. The device must be able to store the data for 90 days.
So while my device so far does everything correctly the thing that I am struggling with is the storage of the data. I initialize an array of a certain size and then store the measurement-result into the array successively. The measurement result is a short int. Point is with an interval of 10 minutes I manage to have an array the size 1850 while (as far as I see it) it must have a size of 13960.
I may be able to expand the interval to 15min but even that would not even get me close. Are there further ways I could decrease the needed RAM which I don't see?
Upvotes: 0
Views: 653
Reputation: 416
Given your restriction it is critical to know your total available memory :
Remember that your program will use a significant part of this memory to run your code (more here).
You can measure your SRAM usage to know how much
If possible don't use Heap (and no dynamic allocation of course)
It is where your code is programmed, every bytes not used by your code is free space for your data storage.
You can measure your SRAM usage to know how much
Unfortunately, this memory is reserved for functional library. Maybe it is possible to overwrite TI's code to put your own in order to gain space. Unless you are a veteran, I strongly advice against it
Let's say you use 1/4 of both memories you have in fact 4KB of available memory, located in SRAM and FRAM (linker script sections)
With some maths you get 12960 data collection for 90 days which is not possible to store
Upvotes: 2
Reputation: 68059
I would use some $0.5 I2C EEPROM like M24256-DFDW6TP. It is very easy even to "dead bug" solder to the actual board and has 32kB of EEPROM. More than you need.
https://uk.farnell.com/stmicroelectronics/m24256-dfdw6tp/eeprom-256kbit-40-to-85deg-c/dp/3214579
Upvotes: 3