| |||
| Home > Configuring Custom Targets > Example descriptions > Setting up a custom register | |||
This example describes the steps to follow to specify a register MYREG,
that appears as a new tab in the Register pane. It also describes
how to set up named bit fields in this register. To set up the custom
register, you must make changes in the Memory_block, Register, Register_enum,
and Register_Window groups.
This example uses the connection created in Setting up an Integrator board and
core module. However, in
this example, the AP and CM940T board
groups are removed to ensure a default registers view.
If you have set up a memory map as described in Configuring a memory map, then delete
the SSRAM entry before you begin.
In this example:
The memory region
used for the new register is called REGS and
is addressed from 0x10000000-0x107FFFFF.
The custom register, named MYREG,
has an offset of 0x20 from the base of the memory
block.
The custom register, MYREG, has
four bit fields. These are used as indicators of the state of the
register and are named INDICATORS. They are labeled IND1, IND2, IND3, and IND4.
The example is split into the following sections, which must be executed in this sequence:
In this stage, you set up a memory group that provides the base address for the new registers:
Ensure that RealView Debugger is not connected to a target.
Select Target → Connect to Target... to display the Connection Control window.
Right-click on the MP3Player entry
and select Connection Properties... from
the context menu.
If the connection has the linked board files from Setting up an Integrator board and
core module, right-click
on the *BoardChip_name AP setting in the right
pane, and select Delete from the context
menu.
Repeat this for the *BoardChip_name CM940T setting.
Expand the following entries in turn:
CONNECTION=MP3Player (change
as required)
Advanced_Information
Default
Expand the Memory_block group.
If the connection has the SSRAM memory
block defined from Configuring a memory map,
right-click on the SSRAM entry in the left pane,
and select Delete from the context menu.
Rename the Default entry under Memory_block to REGS.
Click on the REGS entry, in the
left pane, to display the group contents.
Set the value of Start, in the
right pane, to 0x10000000.
Set the value of Length to 0x800000.
Set the value of Description to I/O
Registers, (shown in Figure 13.23).
Select File → Save Changes to save the these changes.
In this stage you set up enumerations, or names for specific values, that are used when the register value is displayed:
Expand Register_enum in
the left pane.
Right-click on Register_enum and
select Make New... to create a new group. Name
this E_SWITCH.
Click on the E_SWITCH entry,
in the left pane, to display the group contents.
Set the value of Names, in the
right pane, to On,Off.
By default, enumerations are numbered 0,1,2,....
However, if you want to give your enumerations specific values,
specify them as “enum1=. For
this example, if you want val1,enum2=val2,...”On to equal 7 and Off to
equal 0 (zero), then enter “On=7,Off=0”.
Rename the Default entry under Register_enum to E_ENABLE.
Click on the E_ENABLE entry,
in the left pane, to display the group contents.
Set the value of the Names entry,
in the right pane, to Disable,Enable, shown in Figure 13.24.
Select File → Save Changes to save the these changes.
In this stage you create descriptions of each register:
Expand the Register group.
Rename the Default entry under Register to Newreg.
Select the Newreg group.
Set the value of Base to REGS.
Set the value of Start to 0x20,
that is the offset from the base address of the REGS memory
block.
Expand the Newreg group.
Expand the Bit_fields group.
You are now going to set up four bit fields.
Rename the Default entry under Bit_fields to IND1.
Use Make Copy... on IND1.
The dialog suggests the name IND2. Click Create.
Use Make Copy... on IND2.
The dialog suggests the name IND3. Click Create.
Use Make Copy... on IND3.
The dialog suggests the name IND4. Click Create.
Click IND1, in the left pane
and set these values, shown in Figure 13.25:
Position=0 (this is the default)
Size=1
Enum=E_ENABLE.
Click on the IND2 entry and set
these values:
Position=1
Size=1
Enum=E_SWITCH.
Click on the IND3 entry and set
these values:
Position=2
Size=4.
Click on the IND4 entry and set
these values:
Position=6
Size=4.
Select File → Save Changes to save the these changes.
In this stage you create a Register_Window group
to display the new register in the Register pane:
Expand the Register_Window group.
Rename the Default entry under Register_Window to MYREG.
This is the name of the new tab in the Register pane.
Click on MYREG, in the left pane.
Click on MYREG, in the left pane.
Set the Line entry, to Newreg.
Use Make New... on *Line to
create a new *Line entry.
Set the *Line entry, to _INDICATORS.
Literals entered in *Line (or Line)
must be preceded by an underscore.
Use Make New... on *Line
“_INDICATORS” to create a new *Line entry.
Set the new *Line to IND1,IND2,IND3,IND4.
The Connection Properties window looks like Figure 13.26.
All board file entries are now complete.
Select File → Save and Close to save your changes and close the Connection Properties window.
In the last stage, display the new register in the Register pane:
Connect to your target.
Select View → Registers to view the new tab, MYREG, shown in Figure 13.27.