Main Content

Memory Allocate

Allocate memory for new variable

Description

The Memory Allocate block, on C2xxx processors, directs the TI compiler to allocate a memory location for a new variable. Block parameters specify the variable name, the alignment of the variable in memory, the data type of the variable, and other features that fully define the memory required.

The block does not verify whether the parameter settings for the variable are valid, such as checking the variable name, data type, or section. You must check that the parameters settings are valid.

You do not connect the Memory Allocation block to other blocks in a model.

Parameters

expand all

Memory

Allocate memory for storing the variable. Specify the data type and size.

Specify the name of the variable for which to allocate memory. The variable is allocated in the generated code.

Select this parameter, if required by your target processor, to direct the compiler to align the new variable to a byte alignment boundary.

Parameter Dependencies

If you select this parameter, use parameter Memory alignment boundary to set the byte alignment boundary.

Specify the alignment boundary for the variable data type in bytes. Alignment can occur on 1-, 2-, 4-, or 8-byte boundaries. If the variable contains multiple values, such as a vector or an array, the block aligns elements according to rules applied by the compiler.

Parameter Dependencies

To enable this parameter, select Specify variable alignment.

Specify the data type for the variable.

Select this parameter to specify a data type qualifier to apply to the variable.

Parameter Dependencies

If you select this parameter, use parameter Data type qualifier to set the data type qualifier to apply to the variable.

Specify the data type qualifier to apply to the variable in generated code as a string or character vector. Common qualifiers are volatile, const, static, and register. The block does not check whether the value that you enter is a valid qualifier.

Specify the number of elements of the specified data type for the variable as a positive integer.

Select this parameter to specify an initial value for the variable.

Parameter Dependencies

If you select this parameter, use parameter Initial value to set the initial value.

Specify the initial value for the variable. At run time, the block sets the memory location to this value.

Parameter Dependencies

To enable this parameter, select Initialize memory.

Section

Specify the memory section in which to allocate the variable.

Select this parameter to specify a memory section to use for allocating space in memory for the variable.

Parameter Dependencies

If you select this parameter, use parameters Memory section, Bind memory section, Section start address to specify memory section details.

Specify the name of the memory section to use for allocating memory for the variable as a string or character vector. Specify a standard memory section or a custom memory section that you declare elsewhere in your code.

Verify that the memory section has enough space to store the variable.

Parameter Dependencies

  • To enable this parameter, select Specify memory section.

  • To bind the specified memory section to a specific start address in memory, select Bind memory section and specify the address by entering a value for Section start address.

Select this parameter to bind a newly created memory section for the variable to a specific start address.

The new memory section specified for Memory section is defined when you select this parameter.

Parameter Dependencies

  • Select this parameter to enable parameter Section start address.

  • Do not select this parameter if you are associating the variable with an existing memory section.

Specify the start address to which to bind the memory section for the variable in decimal form or in hexadecimal form with a conversion to decimal as shown by the default value hex2dec('8000'). The block does not verify the address. Verify that the address that you specify exists and that it can contain the specified memory section.

Parameter Dependencies

  • Enable this parameter by selecting parameter Bind memory section.

  • Do not specify a value for this parameter if you are associating the variable with an existing memory section.

See Also

Introduced in R2011a