| Embedded IDE Link™ CC | ![]() |
reg = regread(cc,'regname','represent',timeout)
reg = regread(cc,'regname','represent')
reg = regread(cc,'regname')
reg = regread(cc,'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® software double datatype. Making this conversion lets you manipulate the data in MATLAB software. String regname specifies the name of the source register on the target. ticcs object cc defines the target to read from. Valid entries for regname depend on your target processor. Register names are not case-sensitive — a0 is the same as A0.
For example, the TMS320C6xxx processor family provides the following register names that are valid entries for regname:
| Register Names | Register Contents |
|---|---|
A0, A1, A2,..., A15 | General purpose A registers |
B0, B1, B2,..., B15 | General purpose B registers |
PC, ISTP, IFR, IRP, NRP, AMR, CSR | Other general purpose 32-bit registers |
A1:A0, A2:A1,..., B15:B14 | 64-bit general purpose register pairs |
Other processors provide other register sets. Refer to the documentation for your target processor to determine the registers for the processor.
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 cc.
reg = regread(cc,'regname','represent') does not set the global time-out value. The time-out value in cc applies.
reg = regread(cc,'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™ CC software.
For the C5xxx processor family, 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, cc is a link for CCS IDE.
cc.regread('PC','binary')
To tell MATLAB software what datatype you are reading, the string binary indicates that the PC register contains a value stored as an unsigned binary integer.
In response, MATLAB software displays
ans =
33824
For processors in the C6xxx family, regread lets you access processor registers directly. To read the value in general purpose register A0, type the following function.
treg = cc.regread('A0','2scomp');
treg now contains the two's complement representation of the value in A0.
Now read the value stored in register B2 as an unsigned binary integer, by typing
cc.regread('B2','binary');
![]() | readnumeric | regwrite | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |