| Embedded IDE Link™ MU | ![]() |
reg = regread(id,'regname','represent',timeout)
reg = regread(id,'regname','represent')
reg = regread(id,'regname')
reg = regread(id,'regname','represent',timeout) reads the data value in the regname register of the target processor and returns the value in reg as a double-precision value. For convenience, regread converts each return value to the MATLAB® double datatype. Making this conversion lets you manipulate the data in MATLAB. String regname specifies the name of the source register on the target. ghsmulti object id defines the target to read from. Valid entries for regname depend on your target processor.
Note regread does not read 64-bit registers, like the cycle register on Blackfin processors. |
Register names are not case-sensitive — a0 is the same as A0.
For example, the following registers are some of the many available on the MPC5500 processor:
'acc' — Accumulator A register
sprg0 through sprg7 — SPR registers
Note Use read (called a direct memory read) to read memory-mapped registers. |
The represent input argument defines the format of the data stored in regname. Input argument represent takes one of three input strings:
| represent String | Description |
|---|---|
2scomp | Source register contains a signed integer value in two's complement format. This is the default setting when you omit the represent argument. |
binary | Source register contains an unsigned binary integer. |
ieee | Source register contains a floating point 32-bit or 64-bit value in IEEE floating-point format. Use this only when you are reading from 32 and 64 bit registers on the target. |
To limit the time that regread spends transferring data from the target processor, the optional argument timeout tells the data transfer process to stop after timeout seconds. timeout is defined as the number of seconds allowed to complete the read operation. You might find this useful for limiting prolonged data transfer operations. If you omit the timeout option in the syntax, regread defaults to the global time-out defined in id.
reg = regread(id,'regname','represent') does not set the global time-out value. The time-out value in id applies.
reg = regread(id,'regname') does not define the format of the data in regname.
Register variables can be difficult to read and write because the registers which hold their value are not dedicated to storing just the variable values.
Registers are used as temporary storage locations at any time during execution. When this temporary storage process occurs, the value of the variable is temporarily stored somewhere on the stack and returned later. Therefore, getting the values of register variables during program execution may return unexpected answers.
Values that you write to register variables during intermediate times in program operation may not get reflected in the register.
This is true for local variables as well.
One way to see this is to write a line of code that uses the variable and see if the result is consistent.
register int a = 100; int b; ... b = a + 2;
Reading the register assigned to a may return an incorrect value for a but if b returns the expected 102 result, nothing is wrong with the code or Embedded IDE Link™ MU software .
For the MPC5554 processor, most registers are memory-mapped and consequently are available using read and write. However, use regread to read the PC register. The following command demonstrates how to read the PC register. To identify the target, id is a ghsmulti object for MULTI.
id.regread('PC','binary')
To tell MATLAB what data type you are reading, the string binary indicates that the PC register contains a value stored as an unsigned binary integer.
In response, MATLAB displays
ans =
33824
For processors in the Blackfin family, regread lets you access processor registers directly. To read the value in general purpose register cycles, type the following function.
treg = id.regread('cycles','2scomp');
treg now contains the two's complement representation of the value in A0.
![]() | read | regwrite | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |