I have big structure with few arrays. For simplicity let's consider structure like this:
typedef struct {
uint32_t data_count;
uint8_t data[512];
uint32_t error_count;
uint8_t errors[512];
} measurements_t;
How many microcontroller CPU cycles does it take to initialize ~1kB structure with zeros?
Does
I'm wondering if I should initialize whole structure with zeroes, or not (assign required data after declaration)?
Does the Cortex-M7 core have any assembly language instruction to fill memory with zeros? I'm not assembly guy, I can't find anything in this manual and I have no access to proper compiler at this moment to check assembly that compiler produces.
measurements_t measurement_results = {0}; // initialization with all zeroes
// or
measurements_t measurement_results; // no initialization
measurement_results.data_count = 0;
measurement_results.error_count = 0;
In fact my struct is more complicated and has few levels and probably more data.
It will be easier to manage code later if I just initialize it with {0}, but if that is cycle-expensive on STM32F7 - I will have to create fast constructor that puts zeroes only where it is really needed for structures like this.