| Embedded IDE Link™ VS | ![]() |
mem = read(vd,address)
mem = read(…,datatype)
mem = read(…,count)
mem = read(…,memorytype)
mem = read(…,timeout)
mem = read(vd,address) returns a block of data values from the memory space of the DSP processor referenced by vd. The block to read begins from the DSP memory location given by the input parameter address. The data is read starting from address without regard to type-alignment boundaries in the DSP. Conversely, the byte ordering defined by the data type is automatically applied.
address is a decimal or hexadecimal representation of a memory address in the DSP. In all cases, the full memory address consist of two parts:
The start address
The memory type
You can use a numeric vector representation of the address (see below) to define the memory type value explicitly .
Alternatively, the vd object has a default memory type value that is applied when the memory type value is not explicitly incorporated in the passed address parameter. In DSP processors with only a single memory type, it is possible to specify all addresses using the abbreviated (implied memory type) format by setting the vd object memory type value to zero.
Note You cannot read data from processor memory while the processor is running. |
Provide the address parameter either as a numerical value that is a decimal representation of the DSP memory address, or as a string that read converts to the decimal representation of the start address. (Refer to function hex2dec in the MATLAB® Function Reference. read uses hex2dec to convert the hexadecimal string to a decimal value).
The examples in the following table demonstrate how read uses 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. 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 = read(…,datatype) where the input argument datatype defines the interpretation of the raw values read from DSP memory. Parameter datatype specifies the data format of the raw memory image. The data is read starting from address without regard to data type alignment boundaries in the DSP. The byte ordering defined by the data type is automatically applied. This syntax supports the following MATLAB data types:
| 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 |
read does not coerce data type alignment. Some combinations of address and datatype will be difficult for the processor to use.
mem = read(…,count) adds the count input parameter that defines the dimensions of the returned data block mem. To read a block of multiple data values, specify count to determine how many values to read from address. count can be a scalar value that causes read to return a column vector that has count values. You can perform multidimensional reads by passing a vector for count. The elements in the input vector of count define the dimensions of the returned data matrix. The memory is read in column-major order. count defines the dimensions of the returned data array mem as shown in the following table.
n — Read n values into a column vector.
[m,n] — Read m-by-n values into m by n matrix in column-major order.
[m,n,...] — Read a multidimensional matrix m-by-n-by…of values into an m-by-n-by…array.
To read a block of multiple data values, specify the input argument count that determines how many values to read from address.
mem = read(…,memorytype) adds an optional input argument memorytype. Object vd has a default memory type value 0 that read 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® processors 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 = read(…,timeout) adds the optional parameter timeout that defines how long, in seconds, MATLAB waits for the specified read process to complete. If the time-out period expires before the read process returns a completion message, MATLAB returns an error and returns control to the MATLAB command prompt. Usually the read process works correctly in spite of the error message.
This example reads one 16–bit integer from memory on the processor.
mlvar = read(vd,131072,'int16')
131072 is the decimal address of the data to read.
You can read more than one value at a time. This read command returns 100 32–bit integers from the address 0x20000 and plots the result in MATLAB.
data = read(vd,'20000','int32',100) plot(double(data))
![]() | profile | remove | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |