Skip to Main Content Skip to Search
Product Documentation

write - Write data to processor memory block

Syntax

mem=IDE_Obj.write(address,data)
mem=write(…,datatype)
mem=IDE_Obj.write(…,memorytype)
mem=IDE_Obj.write(…,timeout)

IDEs

This function supports the following IDEs:

Description

mem=IDE_Obj.write(address,data) writes data, a collection of values, to the memory space of the DSP processor referenced by IDE_Obj.

The data argument is a scalar, vector, or array of values to write to the memory of the processor. The block to write begins from the DSP memory location given by the input parameter address.

The method writes the data starting from address without regard to type-alignment boundaries in the DSP. Conversely, the byte ordering of the data type is automatically applied.

The address argument is a decimal or hexadecimal representation of a memory address in the processor. In all cases, the full memory address consist of two parts: the start address and the memory type. The memory type value can be explicitly defined using a numeric vector representation of the address.

Alternatively, the IDE_Obj object has a default memory type value which is applied if the memory type value is not explicitly incorporated into the passed address parameter. In DSP processors with only a single memory type, by setting the IDE_Obj object memory type value to zero it is possible to specify all addresses using the abbreviated (implied memory type) format.

You provide the address argument either as a numerical value that is a decimal representation of the DSP memory address, or as a string that write converts to the decimal representation of the start address. (Refer to function hex2dec in the MATLAB Function Reference that read uses to convert the hexadecimal string to a decimal value).

The following examples demonstrate how write uses the address argument.

address Parameter ValueDescription
131082Decimal address specification. The memory start address is 131082 and memory type is 0. This action is the same as specifying [131082 0].
[131082 1]Decimal address specification. The memory start address is 131082 and memory type is 1.
'2000A'Hexadecimal address specification provided as a string entry. The memory start address is 131082 (converted to the decimal equivalent) and memory type is 0.

It is possible to specify address as cell array, in which case you can use a combination of numbers and strings for the start address and memory type values. For example, the following are valid addresses from cell array myaddress:

myaddress1 myaddress1{1} = 131072; myadddress1{2} = 'Program(PM) Memory';

myaddress2 myaddress2{1} = '20000'; myadddress2{2} = 'Program(PM) Memory';

myaddress3 myaddress3{1} = 131072; myaddress3{2} = 0;

mem=write(…,datatype) where the datatype argument defines the interpretation of the raw values written to DSP memory. The datatype argument specifies the data format of the raw memory image. The data is written starting from address without regard to data type alignment boundaries in the DSP. The byte ordering of the data type is automatically applied. The following MATLAB data types are supported.

MATLAB Data TypeDescription
doubleIEEE double-precision floating point value
singleIEEE single-precision floating point value
uint88-bit unsigned binary integer value
uint1616-bit unsigned binary integer value
uint3232-bit unsigned binary integer value
int88-bit signed two's complement integer value
int1616-bit signed two's complement integer value
int3232-bit signed two's complement integer value

write does not coerce data type alignment. Some combinations of address and datatype will be difficult for the processor to use.

mem=IDE_Obj.write(…,memorytype) adds an optional memorytype argument. Object IDE_Obj has a default memory type value 0 that write applies if the memory type value is not explicitly incorporated into the passed address parameter. In processors with only a single memory type, it is possible to specify all addresses using the implied memory type format by setting the value of the IDE_Obj memorytype property to zero.

mem=IDE_Obj.write(…,timeout) adds the optional timeout argument, which the number of seconds MATLAB waits for the write process to complete. If the timeout period expires before the write process returns a completion message, MATLAB throws an error and returns. Usually the process works correctly in spite of the error message.

Using write with VisualDSP++ IDE

Blackfin and SHARC use different memory types. Blackfin processors have one memory type. SHARC processors provide five types. The following table shows the memory types for both processor families.

String Entry for memorytypeNumerical Entry for memorytypeProcessor Support
'program(pm) memory'0Blackfin and SHARC
'data(dm) memory'1SHARC
'data(dm) short word memory'2SHARC
'external data(dm) byte memory'3SHARC
'boot(prom) memory'4SHARC

Examples

Example with VisualDSP++ IDE

These three syntax examples demonstrate how to use write in some common ways. In the first example, write an array of 16-bit integers to location [131072 1].

IDE_Obj.write([131072 1],int16([1:100]));

Now write a single-precision IEEE floating point value (32-bits) at address 2000A(Hex).

IDE_Obj.write('2000A',single(23.5));

For the third example, write a 2-D array of integers in row-major format (standard C programming format) at address 131072 (decimal).

mlarr = int32([1:10;101:110]);
IDE_Obj.write(131072,mlarr');

See Also

hex2dec | read

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS