The programming sequence is identical when using
the SEC units, regardless of whether the debug software or the application is
programing the units. Typical programming sequence for a unit is:
- Read and make sure the
ownership is set as expected. If not, acquire the ownership before
proceeding further if required.
- Make sure the unit is in IDLE
mode.
- Set up the counter reference,
counter registers (clear/reset if a clean start is required) and
CTM_CNTL.
- Enable the corresponding
module bit in the global enable register.
- Once the usage is completed,
write 1 to clear the EVENT_FIRED sticky bit. This takes the module back to
the enabled state.
Set up a free running counter:
- Read and make sure the
ownership is set as expected. If not, acquire the ownership before
proceeding further, if required.
- Read CTM_STATUS to confirm
that the module is in IDLE state.
- Write 0x0 to
CTM_INPUT_SEL.
- Write 0x0 to CTM_CNTL.
- Enable the module in the
GLBL_ENABLE register.
Set up the counter to count the duration spent
between addresses 0x1000 and 0x1210:
- Read and make sure the
ownership is set as expected. If not, acquire the ownership before
proceeding further, if required.
- Read CTM_STATUS to confirm
that the module is in IDLE state.
- Set up the EBC unit 1 to
generate an event for VPC = 0x1000.
- Set up the EBC unit 2 to
generate an event for VPC = 0x1210.
- Set up the start and stop input selects to use comparator event 1 and 2,
respectively. This is achieved by writing CTM_INPUT_SEL.STA_INP_SEL = 0x0
and CTM_INPUT_SEL_2.STO_INP_SEL = 0x1.
- Enable the counter in the START_STOP_MODE of operation. This is achieved by
writing CTM_CNTL. START_STOP_MODE = 1.
- Enable the module in the
GLBL_ENABLE register.
Set up the counter to count the number of times a
function at address 0x2010 is called and fire an RTOSINT if this count reaches
0x300:
- Read and make sure the
ownership is set as expected. If not, acquire the ownership before
proceeding further, if required.
- Read CTM_STATUS to confirm
that the module is in IDLE state.
- Set up the EBC unit 1 to
generate an event for VPC = 0x2010.
- Setup the counter to select comparator event 1 as the event to count. This
is achieved by writing CTM_INPUT_SEL.CNT_INP_SEL= 0 and
CTM_CNTL.CNT_INP_SEL_EN = 1.
- Write 0x300 CTM_REF.
- Enable the counter in the
EVENT_MODE, and also allow the counter to generate an RTOSINT when the count
matches the reference. This is achieved by writing 0x88 to CTM_CNTL (bit 3 =
1 and bit 7 = 1).
- Enable the module in the
GLBL_ENABLE register.