Skip to main content
DCtech
Associate III
February 11, 2022
Question

Data to Store Array

  • February 11, 2022
  • 1 reply
  • 1002 views

I keep the important information in 32 byte. But every block have 32 byte .There are more than 300 block and every block have 32 bytes of data. So I've 32*300 byte data. How can I keep in the RAM successfully. Sould I Keep with array (uint32_t) or pointer (malloc, alloc functions) ? Which one is logical and how ? I am using stm32f4 with 192kb RAM so RAM is surely enough. When I use this values I want to clear-free the memory.

This topic has been closed for replies.

1 reply

KnarfB
Super User
February 11, 2022

I would use a global variable here, if your data is structured something like

struct record { int x; int y; /* more */ };
 
struct record data[300];
 
 for( int i=0; i<300; ++i ) {
 data[i].x = 42;
 }

Embedded programming should be as static as possible, so no malloc if not neccessary. You don't want to run out of resources at run-time.

hth

KnarfB