| Embedded IDE Link™ MU | ![]() |
regwrite(id,'regname',value,'represent',timeout)
regwrite(id,'regname',value,'represent')
regwrite(id,'regname',value,)
regwrite(id,'regname',value,'represent',timeout) writes the data in value to the regname register of the target processor. regwrite converts value from its representation in the MATLAB® workspace to the representation specified by represent. The represent input argument defines the format of the data when it is stored in regname. Input argument represent takes one of three input strings:
| represent String | Description |
|---|---|
2scomp | Write value to the destination register as a signed integer value in two's complement format. This is the default setting when you omit the represent argument. |
binary | Write value to the destination register as an unsigned binary integer. |
ieee | Write value to the destination registers as a floating point 32-bit or 64-bit value in IEEE floating-point format. Use this only when you are writing to 32- and 64-bit registers on the target. |
String regname specifies the name of the destination register on the target. Link id defines the target to write value to. Valid entries for regname depend on your target processor. 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
Other processors provide other register sets. Refer to the documentation for your target processor to determine the registers for the processor.
Note Use write (called a direct memory write) to write memory-mapped registers. |
To limit the time that regwrite spends transferring data to 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 write operation. You might find this useful for limiting prolonged data transfer operations.
If you omit the timeout input argument in the syntax, regwrite defaults to the global time-out defined in id. If the write operation exceeds the time specified, regwrite returns with a time-out error. Generally, time-out errors do not stop the register write process. The write process stops while waiting for MULTI to respond that the write operation is complete.
regwrite(id,'regname',value,'represent') omits the timeout input argument and does not change the time-out value specified in id.
regwrite(id,'regname',value,) omits the represent input argument. Writing the data does not reformat the data written to 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 any local variables as well.
One way to see this is to write a line of code that uses the variable and see if 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.
To write a new value to the PC register on a C5xxx family processor, enter
regwrite(id,'pc',hex2dec('100'),'binary')
specifying that you are writing the value 256 (the decimal value of 0x100) to register pc as binary data.
To write a 64-bit value to a register pair, such as B1:B0, the following syntax specifies the value as a string, representation, and target registers.
regwrite(id,'b1:b0',hex2dec('1010'),'ieee')
Registers B1:B0 now contain the value 4112 in double-precision format.
![]() | regread | remove | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |