regwrite - Write data values to registers on target processor

Syntax

regwrite(cc,'regname',value,'represent',timeout)
regwrite(cc,'regname',value,'represent')
regwrite(cc,'regname',value,)

Description

regwrite(cc,'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® software 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 StringDescription

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. cc 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 C6xxx processor family provides the following register names that are valid entries for regname:

Register NamesRegister 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.

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 cc. 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 CCS IDE to respond that the write operation is complete.

regwrite(cc,'regname',value,'represent') omits the timeout input argument and does not change the time-out value specified in cc.

regwrite(cc,'regname',value,) omits the represent input argument. Writing the data does not reformat the data written to regname.

Reading and Writing Register Values

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™ CC software.

Examples

To write a new value to the PC register on a C5xxx family processor, enter

regwrite(cc,'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(cc,'b1:b0',hex2dec('1010'),'ieee')

Registers B1:B0 now contain the value 4112 in double-precision format.

See Also

read, regread, write

  


 © 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