Control Memory Allocation for Time Counters

The Application lifespan (days) parameter lets you control the allocation of memory for absolute and elapsed time counters. Such counters exist in the code for blocks that use absolute or elapsed time. For a list of such blocks, see Absolute Time Limitations.

The size of the time counters in generated code is 8, 16, 32, or 64 bits. The size is set automatically to the minimum that can accommodate the duration value specified by Application lifespan (days) given the step size specified in the Configuration Parameters Solver pane. To minimize the amount of RAM used by time counters, specify the smallest lifespan possible and the largest step size possible.

An application runs to its specified lifespan. It may be able to run longer. For example, running a model with a step size of one millisecond (0.001 seconds) for one day requires a 32-bit timer, which could continue running without overflow for 49 days more.

To maximize application lifespan, specify Application lifespan (days) as inf. This value allocates 64 bits (two uint32 words) for each timer. Using 64 bits to store timing data would allow a model with a step size of 0.001 microsecond (10E-09 seconds) to run for more than 500 years, which would rarely be required. 64-bit counters do not violate the usual code generator length limitation of 32 bits because the value of a time counter does not provide the value of a signal, state, or parameter.

See Also

Related Topics