read - Read data from processor memory

Syntax

mem = read(vd,address)
mem = read(…,datatype)
mem = read(…,count)
mem = read(…,memorytype)
mem = read(…,timeout)

Description

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:

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.

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 ValueDescription
131082Decimal 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 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

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.

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 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

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.

Examples

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))

See Also

write

  


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