The eICE debug interface provides a serial communication interface for an external device (eICE master) to read and write the memory and register space of eCOG1 (slave) and control CPU state and program execution with various debug commands. Access to Memory and Registers can take place in real time with the CPU running or halted. eICE functions include:
The communication mechanism consists of a shift register inside eCOG1 which has fields for a 32-bit eICE command and 32 bits of data. Although it is possible to shift in 16 bits of write data and a 32-bit command, it is recommended that a fixed communication structure of 32 bits of data and 32-bit command is used; this simplifies eICE master design and data handling. See Section F.4, eICE Command and Data Shift, for details on where data appears for 16 bit reads and writes.
The data field is used for both read and write operations. If the eICE command is for a write, the command and write data are shifted in; if the eICE command is a read then only the command is shifted in. On completion of the command, the read data is available in the data section of the shift register for shifting out.
Once shifted in, the eICE slave decodes and executes the eICE command which may be a memory read or write, register read or write, CPU or other control function. If the eICE command is a read, the read data is available for shifting out on completion of the eICE command.
The eICE port uses the following eCOG1X pins:
|
Master Out Slave In, the serial debug data stream into eCOG1. |
|
|
Master In Slave Out, the serial debug data stream from eCOG1. ** |
|
The following diagram shows the eICE connections at the eCOG1 device level. Note that the signal eICE_LOADB denotes the single, bidirectional connection of MST_LOADB and SLV_LOADB.
** The eICE_LOADB signal is a single point connection of two open drain signals at a pull-up resistor, as shown in the diagram below. This enables a handshake sequence to take place with eICE_LOADB as a bidirectional signal and either the master or the slave controlling the single pin. The eICE_MISO signal is also used as part of the handshake, see Section F.2, Handshake.
When eICE_LOADB is high, the eICE_MISO serial stream contains the data read from the previous eICE command. When eICE_LOADB is low, the eICE_MISO signal is used as part of the master/slave handshaking as described below.
eICE_CLK is the clock signal used to shift in the eICE command and data, and is provided by the master. This is not a free running clock and is required to be suspended by the master, after the appropriate number of bits are shifted.
eICE_LOADB is both a control and handshake signal for eICE. It is an open drain signal which is driven low by the master and/or the slave to control transfers.
The eICE communication handshake and eICE command/data shift in procedure works as follows.
Normally eICE_LOADB is released high by both the master and the slave.
Whilst eICE_LOADB is high, the master can shift in the frame (eICE command and data) to the slave. When the master finishes shifting the frame to the slave, it holds eICE_CLK low and then pulls eICE_LOADB low.
At this point, the slave sets eICE_MISO high. eICE_MISO remains high until the slave has recognised the presence of the frame sent by the master. Once the slave has recognised the frame it holds eICE_LOADB low and then sets eICE_MISO low. When the master sees the low going transition on eICE_MISO it releases eICE_LOADB. Since the slave is holding eICE_LOADB low, the master has an indication that the slave has received, and is executing, the eICE command. When the slave has completed the eICE command, it releases eICE_LOADB, the master observes eICE_LOADB going high and can then shift out the eICE command response and/or shift in a new eICE command. It is possible to shift out the response concurrently with shifting in a new eICE command. See the eICE handshake diagram below.
The master may abort a pending eICE command while eICE_LOADB is held low by the slave. This is done by the master issuing 32 clock pulses on the eICE_CLK signal while eICE_LOADB is held low.
When the eCOG1 eICE detects an abort condition, it aborts the current instruction and returns the internal hardware to a safe state. The abort condition may therefore also be used to initialise the eCOG1 eICE after a power on. It is recommended that the external eICE master performs this initialisation when connecting to the eICE slave.
The eICE_MOSI serial stream contains the serial eICE command and data from master to slave as described in Section F.8, eICE Commands. Commands are shifted into the eICE slave, which then decodes and executes the received eICE command.
Note that the eICE command field contains the Read/Write bit in the MSB (bit 31). For eCOG1 this bit should be set to '1' for a read and '0' for a write.
For example, a write to register AH requires an eICE command field of 0x02000100, and a read of register AH requires an eICE command field of 0x82000100. The eICE command field is fixed at 32 bits and the data field is also 32 bits.
The sequence of the shift in operation from the master is first the data field, then the eICE command field, MSB first. For 32-bit data and command, the sequence is data[31] first, followed by the remaining 31 bits of data, then command bit [31] (R/W bit) followed by the remaining 31 bits of the eICE command. See Figure 146, eICE timing for a write to slave. The master supplies the necessary number of clock pulses on eICE_CLK, i.e. 64 clocks for a 32 + 32 bit shift.
The sequence of the shift out operation from the slave is also controlled by the master, since it supplies eICE_CLK. The bit order of the serial shift out is first the data field starting from the MSB (bit 31), followed by the eICE command field starting from the MSB (bit 31). See Figure 147, eICE timing for a read from slave. Note that for a single word (16 bit) read, the read data appears in the least significant 16 bits.
A 'tag' read operation is one where the eICE command is a read of a single word (16 bit) memory location. By initialising the msb_rd_src field in the Mode register before the command is issued, it is possible to 'tag' a read of a 16 bit register into the spare 16 bits of the data field. Where a 'tag' read has been performed, the 'tag' data appears in the 16 most significant bits, with the normal read data again in the 16 least significant bits.
The eICE Master drives eICE_CLK to shift in eICE command and data words to the eCOG1. This clock is used to fill the eICE shift register in eCOG1. However, all other slave eICE logic is clocked by the asynchronous CPU clock.
The input stream (data and command) and the output stream are timed from the leading edge of eICE_CLK. The shift register inside the eCOG1 eICE captures data on the trailing edge of eICE_CLK and shifts data out on the leading edge of eICE_CLK. This means that both the input stream (write data and command) and the output stream (read data) are timed from the leading edge of eICE_CLK.
It should be noted that immediately after a power-on reset, the CPU clock may be running slowly from a low-speed crystal oscillator. This means that some care must be taken with initial eICE operations. The eICE_CLK may be clocked faster than the CPU clock, but the eICE handshake protocol must be observed and there should be 4 CPU clock periods between eICE transactions. The CPU clock frequency may be increased by writing a suitable value to the cpu_clk_div field in the ssm.cpu register via eICE. Once the CPU clock rate is increased, the rate of eICE transactions may also be increased, limited only by the handshake protocol which remains fundamentally dependent on 4 CPU clock cycles.
The level of the eICE_LOADB input signal is sampled as the processor comes out of reset. If the signal is high, then the processor enters the RUN state and programme execution starts from the reset vector. If the eICE_LOADB_IN is low when the CPU comes out of reset, then the processor enters the STOP state and no programme execution occurs.
This is useful to prevent the CPU from attempting to execute code from an unprogrammed flash, or if there is erroneous code programmed into the flash memory that prevents eICE communication when execution starts after reset.
There are two registers available specifically for eICE control and status. These registers are not CPU or I/O mapped registers but are specifically and solely for the use of eICE. They are accessed only with specific eICE commands, see table later in this section.
The mode register is used to configure and control the operation of subsequent eICE cycles. The following table describes the operation of each bit field. This register is read and written through eICE.
** If an eICE command for a single word memory read is required, it is possible to 'tag' a read of the AH register or the PC program counter (lower 16 bits only) into the unused most significant 16 bits of data in the 32-bit data field.
A 10 bit status register is provided for eICE. The following table outlines the operation of each bit. See the relevant eICE command in Section F.8. This register is read only.
|
Set when an eICE cycle
is aborted.
|
||
|
Indicates the status of the core control mode step bit. Set when the CPU is commanded to execute a single step or run to a breakpoint, cleared when commanded to run normally or stop. |
||
|
Indicates the status of the core control mode run bit. Set when the CPU is commanded to run normally or to a breakpoint, cleared when commanded to stop or execute a single step. |
||
|
Set when the CPU stops because of a Code Address, Data Address Read or Data Address Write break. |
||
|
Shows the state of the
eICE Debug Enable bit (DE).
This bit must be set in order to execute any debug commands or access CPU core registers. Memory (code and data) and peripheral registers are accessible via eICE without this bit set. |
The eCOG1X eICE block implements five Code Address hardware breakpoints and one Data Value/Address hardware breakpoint.
The code space addresses for the five Code Address breakpoints are stored in registers BRKREG0 to BRKREG4 as 24-bit values. These can be read and written either as one 8-bit and one 16-bit value, or as a single 24-bit value. When the program counter matches the code space address value in one of the Code Address break registers and (for BRKREG1 to BRKREG4) the breakpoint is enabled, a break occurs and program execution stops before the instruction at this address is executed.
The Data Value/Address breakpoint is controlled by four registers, each containing a 16-bit value. These are arranged as two pairs, one for the address and one for the data value, each pair comprising a match register and a mask register. When a data space access occurs, both the address and the data value are ANDed with their mask register values and then checked against their match register values. Bit positions set to '0' in the mask register are compared, while bit positions set to '1' in the mask register are ignored. If all address and data bits included in the comparison are the same as those set in the match registers, then a break occurs and execution stops.
When a break occurs, the break_status bit in the eICE status register is set. This bit is cleared when a Stop command is received.
The BRKENABLE register controls which breakpoints are enabled and disabled.
Note that the first code address breakpoint in BRKREG0 is always enabled.
The register contains the following fields.
The following table contains the eICE commands that the eICE debugger performs. Note that the hexadecimal code is defined for the full 32-bit eICE command, and assumes that the R/W bit (bit 31) is set to '0' for a write.