| Embedded IDE Link™ VS | ![]() |
mem = write(vd,address,data)
mem = write(…,datatype)
mem = write(…,memorytype)
mem = write(…,timeout)
mem = write(vd,address,data) writes data, a collection of values, to the memory space of the DSP processor referenced by vd. Input argument data 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 data is written starting from address without regard to type-alignment boundaries in the DSP. Conversely, the byte ordering of the data type is automatically applied.
Note You cannot write data to processor memory while the processor is running. |
address 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 (see below).
Alternatively, the vd 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 vd object memory type value to zero it is possible to specify all addresses using the abbreviated (implied memory type) format.
You provide the address parameter 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).
To demonstrate how write uses address, here are some examples of the address parameter:
| address Parameter Value | Description |
|---|---|
| 131082 | Decimal address specification. The memory start address is 131082 and memory type is 0. This 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 a 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 input argument datatype defines the interpretation of the raw values written to DSP memory. Parameter datatype 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 Type | Description |
|---|---|
| double | IEEE double-precision floating point value |
| single | IEEE single-precision floating point value |
| uint8 | 8-bit unsigned binary integer value |
| uint16 | 16-bit unsigned binary integer value |
| uint32 | 32-bit unsigned binary integer value |
| int8 | 8-bit signed two's complement integer value |
| int16 | 16-bit signed two's complement integer value |
| int32 | 32-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 = write(…,memorytype) adds an optional input argument memorytype. Object vd 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 vd memorytype property value to zero.
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 memorytype | Numerical Entry for memorytype | Processor Support |
|---|---|---|
| 'program(pm) memory' | 0 | Blackfin and SHARC |
| 'data(dm) memory' | 1 | SHARC |
| 'data(dm) short word memory' | 2 | SHARC |
| 'external data(dm) byte memory' | 3 | SHARC |
| 'boot(prom) memory' | 4 | SHARC |
mem = write(…,timeout) adds the optional parameter timeout that defines how long, in seconds, MATLAB waits for the specified write process to complete. If the timeout period expires before the write process returns a completion message, MATLAB displays an error and returns control to the command prompt. Usually the process works correctly in spite of the error message.
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].
write(vd,[131072 1],int16([1:100]));
Now write a single-precision IEEE floating point value (32-bits) at address 2000A(Hex).
write(vd,'2000A',single(23.5));
For the third example, write a 2-D array of integers in row-major format (standard ANSI C code programming format) at address 131072 (decimal).
mlarr = int32([1:10;101:110]); write(vd,131072,mlarr);
hex2dec in the MATLAB Function Reference
![]() | visible | Block Reference | ![]() |
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |