AN1935
AN1935
Rev. 1, 11/2005
Application Note
1. Introduction
3.3 Transferring Data To and From the
JTAG Port............................................. 8
3.4 Preparing for OnCE Module Access.... 9
This Application Note describes the internal structure of the
JTAG port and OnCE module and their functionality with respect 4. Algorithms for Communication with the
to accessing the on-chip Flash memory units. The following OnCE Module ..................................10
sections describe algorithms which must be implemented and 4.1 Executing One-Word Instructions ..... 11
their implementation using C programming language. 4.2 Execution Two-Word Instructions..... 11
4.3 Instruction Set Supported by the
OnCE Module.....................................12
2. JTAG Port and OnCE Module 4.4 Reading Data Out of the Device Core12
4.5 Instruction Execution - Examples ...... 12
The JTAG port is a dedicated user-accessible TAP, compatible with the IEEE 1149.1a-1993 Standard Test
Access Port and Boundary Scan Architecture. Problems associated with testing high-density circuit boards
have led to the development of this proposed standard under the sponsorship of the Test Technology
Committee of IEEE and JTAG. The 56800 series of components supports circuit board test strategies based on
this standard.
Five dedicated pins interface to the TAP, which contains a 16-state controller. The TAP uses a boundary scan
technique to test the interconnections between integrated circuits after they are assembled onto a printed circuit
board (PCB). Boundary scans allow a tester to observe and control signal levels at each component pin through
a shift register placed next to each pin. This is important for testing continuity and determining if pins are stuck
at the one or zero level.
Features of the TAP port include:
• Perform boundary scan operations to test circuit board electrical continuity
• Bypass the device for a given circuit board test by replacing the boundary scan register (BSR) with a
single-bit register
• Sample the device system pins during operation and transparently shift out the result in the CSR;
pre-load values to output pins prior to invoking the EXTEST instruction
• Disable the output drive to pins during circuit board testing
• Provide a means of accessing the OnCE module controller and circuits to control a target system
• Query identification information, manufacturer, part number, and version from a chip
• Force test data onto the outputs of a device IC while replacing its BSR in the serial data path with a
single bit register
• Enable a weak pull-up current device on all input signals of a device IC, helping to assure deterministic
test results in the presence of continuity fault during interconnect testing
The OnCE module is a Freescale-designed module used in Digital Signal Controller (DSC) chips to debug
application software employed with the chip. The port is a separate on-chip block allowing non-intrusive
device interaction with accessibility through the pins of the JTAG interface. The OnCE module makes it
possible to examine registers, memory, or on-chip peripherals’ contents in a special debug environment. This
avoids sacrificing any user-accessible on-chip resources to perform debugging procedures. Additionally, on
the 56F80x, the JTAG/OnCE port can be used to program the internal Flash memory OnCE module.
17The capabilities of the OnCE module include the ability to:
• Interrupt or break into Debug Mode on a program memory address: fetch, read, write, or access
• Interrupt or break into Debug mode on a data memory address: read, write, or access
• Interrupt or break into Debug Mode on an on-chip peripheral register access: read, write, or access
• Enter Debug Mode using a device microprocessor instruction
• Display or modify the contents of any device core register
• Display or modify the contents of peripheral memory-mapped registers
• Display or modify any desired sections of program or data memory
• Trace one, single stepping, or as many as 256 instructions
• Save or restore the current state of the chip’s pipeline
• Display the contents of the real-time instruction trace buffer, whether in Debug Mode or not
• Return to user mode from Debug Mode
• Set up breakpoints without being in Debug Mode
• Set hardware breakpoints, software breakpoints, and trace occurrences (OnCE events), possibly
forcing the chip into Debug Mode; force a vectored interrupt; force the real-time instruction buffer to
halt; or toggle a pin, based on the user’s needs
TDI Test Data Input — This input provides a serial data stream to the JTAG and the OnCE
module. It is sampled on the rising edge of TCK and has an on-chip pull-up resistor.
TDO Test Data Output — This tri-stateable output provides a serial data stream from the
JTAG and the OnCE module. It is driven in the Shift-IR and Shift-DR controller states of
the JTAG state machine and changes on the falling edge of TCK.
TMS Test Mode Select Input — This input sequences the TAP controller’s state machine. It
is sampled on the rising edge of TCK and has an on-chip pull-up resistor.
TCK Test Clock Input — This input proves a gated clock to synchronize the test logic and
shift serial data through the JTAG/OnCE port. The maximum frequency for TCK is 1/8
the maximum frequency of the 56F80x (i.e., 5MHz if the IP Bus clock is 40MHz). The
TCK pin has an on-chip pull-down resistor.
TRST Test Reset — This input provides a reset signal to the TAP controller. This pin has an
on-chip pull-up resistor.
DE Debug Event — Assertion of this output signals that the OnCE event has occurred
ID Register
Boundary Scan
Instruction Reg.
Instruction
Decoder
TMS
TAP
TCK Controller
TRST *
TDO
* TRST signal is not required for JTAG/OnCE access
Timing of the JTAG signals is shown in Figure 2-2. The TDO pin remains in the high impedance state except
during the shift-DR or shift-IR controller states. In these controller states, TDO is updated on the falling edge
of TCK. TDI and TMS are sampled on the rising edge of TCK.
TCK
The TAP controller is a synchronous finite-state machine containing sixteen states, as illustrated in Figure 2-3.
The TAP controller responds to changes at the TMS and TCK signals. Transitions from one state to another
occur on the rising edge of TCK. The value shown adjacent to each state transition in this figure represents the
signal present at TMS at the time of a rising edge at TCK.
There are two paths through the 16-state TAP machine. The Instruction path captures and loads JTAG
instructions into the Instruction Register. The Data path captures and loads data into the other JTAG registers
and also provides a path for communicating with the OnCE module. The TAP controller executes the last
instruction decoded until a new instruction is entered at the Update-IR state, or until the Test-Logic-Reset state
is entered. When using the JTAG port to access OnCE module registers, accesses are first enabled by shifting
the ENABLE_ONCE instruction into the JTAGIR. After this is selected, the OnCE module registers and
commands are read and written through the JTAG pins using the Data path. Asserting the JTAG’s TRST pin
asynchronously forces the JTAG state machine into the Test-Logic-Reset state.
1 Test-Logic-Reset
0
Data Instructions
1 1 1
0 Run-Test-Idle Select-DR-Scan Select-IR-Scan
0 0
1 1
Capture-DR Capture-IR
0 0
Shift-DR 0 Shift-IR 0
1 1
1 1
Exit1-DR Exit1-IR
0 0
Pause-DR 0 Pause-IR 0
1 1
0 0
Exit2-DR Exit2-IR
1 1
Update-DR Update-IR
1 0 1 0
JTAG/OnCE and these signals are not used in the algorithms. The user is expected to reset the JTAG TAP state
machine to Test-Logic-Reset state at power-up by asserting the TRST pin as indicated in the chip datasheet.
Where hardware measures are provided on the proprietary target platform for asserting the TRST pin, external
connection to this pin is not required.
The primitives are:
• JTAG_TCK_SET
• JTAG_TCK_RESET
• JTAG_TMS_SET
• JTAG_TMS_RESET
• JTAG_TDI_SET
• JTAG_TDI_RESET
• JTAG_TDO_VALUE
The JTAG_XXX_SET primitives assert the respective signal (logical Hi). The JTAG_XXX_RESET
primitives deassert the respective signal (logical Lo). The JTAG_TDO_VALUE primitive returns a value of 0
or 1 when the TDO pin is in logical Hi or Lo state, respectively.
Based on TDI-related primitives, it’s possible to define one more:
#define JTAG_TDI_ASSIGN(i)if (i&0x0001) JTAG_TDI_SET; else JTAG_TDI_RESET
This primitive asserts the TDI signal for all odd arguments and deasserts it for all even arguments.
0000 EXTEST
0001 SAMPLE/PRELOAD
0010 IDCODE
0011 EXTEST_PULLUP
0100 HIGHZ
0101 CLAMP
0110 ENABLE_ONCE
0111 DEBUG_REQUEST
1111 BYPASS
While a new instruction is shifted in through the TDI pin, the TDO pin outputs status information. The status
has the following 4-bit format:
OS1 OS0 0 1
The LSB is shifted out first. The OS0 and OS1 bits indicate the current state of the device; see Table 3-2.
IDCODE Instruction
The IDCODE instruction enables the 32-bit wide ID Register between TDI and TDO. It is provided as a public
instruction that allows the determination of the manufacturer, part number, and version of a component
through the TAP.
The instruction is not really necessary for accessing the Flash memories, but is useful for determining the part
number and version of the attached chip.
DEBUG_REQUEST Instruction
The DEBUG_REQUEST instruction asserts a request to halt the core for entry to Debug Mode. It is typically
used in conjunction with ENABLE_ONCE to perform system debug functions. It is provided as a public
instruction. When the DEBUG_REQUEST instruction is invoked, the TDI and TDO pins are connected to the
bypass register.
ENABLE_ONCE Instruction
The ENABLE_ONCE instruction enables the JTAG port to communicate with the OnCE state machine and
registers. It is provided to allow the user to perform system debug functions. When the ENABLE_ONCE
instruction is invoked, the TDI and TDO pins are connected directly to the OnCE registers. The particular
OnCE register connected between TDI and TDO is selected by the OnCE state machine and the OnCE
instruction being executed. All communication with the OnCE instruction controller is done through the Data
path of the JTAG state machine.
To execute the JTAG instruction, bring the TAP state machine to the Shift-IR phase, shift in the new
instruction and bring the TAP state machine to the Update-IR state to decode the new instruction.
Implementation of this algorithm is demonstrated in Code Example 3-1.
JTAG_TCK_RESET;
JTAG_TCK_SET;
JTAG_TMS_RESET; /* Go to Capture-DR */
JTAG_TCK_RESET;
JTAG_TCK_SET;
JTAG_TCK_RESET;
JTAG_TCK_SET; /* Go to Shift-DR */
JTAG_TCK_RESET; /* TAP is now in Shift-DR state */
for (i=0;i<bit_count;i++) {
JTAG_TDI_ASSIGN(data);
data>>=1;
if (i==(bit_count-1)) JTAG_TMS_SET; /* Go to Exit1-DR */
JTAG_TCK_SET;
result>>=1;
result|=((unsigned long int)JTAG_TDO_VALUE)<<(bit_count-1);
JTAG_TCK_RESET;
}
JTAG_TCK_SET; /* Go to Update-DR */
JTAG_TMS_RESET; /* Go to Run-Test-Idle */
JTAG_TCK_RESET;
JTAG_TCK_SET;
return(result);
}
The OnCE module has its own instruction register (OCMDR) and instruction decoder. After a command is
latched into the OCMDR, the command decoder implements the instruction through the OnCE state machine
and control block. There are two types of commands:
1. Read commands, causing the chip to deliver required data
2. Write commands, transferring data into the chip, then writing it in one of the on-chip resources
The commands are eight bits long and have the format displayed in Table 4-1. The lowest five bits, RS0 - RS4,
identify the source for the operation, described in Table 4-2. Bits 5, 6, and 7 contain the exit bit, EX, the
execute bit, GO, and the read/write bit, R/W.
01010 OnCE Program Address Register—Fetch cycle (OPABFR) FIFO halted Read
10000 OnCE Program Address Register—Execute cycle (OPABER) FIFO halted Read
10011 OnCE Program Address Register—Decode cycle (OPABDR) FIFO halted Read
When the exit bit, EX, is set, the device core will exit the Debug processing state after the command is
executed; otherwise, the Debug state is preserved. The execute bit, GO, signals that the device core instruction
should be executed. The read/write bit, R/W, indicates whether a read or write operation should be performed
with the register selected by the RS bits.
It is possible to define a new macro for executing OnCE commands:
The reset values of the FIU timing registers are optimized for full-speed operation of the chip when the IP Bus
Clock receives 40MHz. To prevent overstress and possible permanent damage of the Flash memories, either
the OCCS unit must be reprogrammed to supply 40MHz to the IP Bus Clock, or the timing registers need to be
reprogrammed with new values suitable for the lower IP Bus Clock frequencies.
The algorithm for initialization of the FIU timing registers is shown in Code Example 5-1.
FIU_CLKDIVISOR 15 15 N/A
FIU_TERASEL 15 2 26.2ms
FIU_TMEL 31 6 52.4ms
FIU_TRCVL 63 6 1.6µs
6. Conclusion
In Sections 3., 4., and 5., a whole library of functions and macros was built, which enables erasing,
programming and verifying contents of the internal Flash memories over the JTAG/OnCE interface. Since the
JTAG signals can be as fast as 5MHz, programming time below 5 seconds can be achieved with the 56F805.
Therefore, the programming technique described here is suitable for even a high-volume production
environment.
7. References
[1.] 56F80x 16-bit Digital Signal Processor, User’s Manual, DSP56F801-7UM, Rev. 3.0, Freescale
Semiconductor, Inc.
[2.] 56F800 Flash Programming via JTAG/OnCE using the Parallel Command Converter, Rev. 0.4, Freescale
Semiconductor, Inc.
E-mail:
support@freescale.com
Japan:
Freescale Semiconductor Japan Ltd.
Headquarters
ARCO Tower 15F
1-8-1, Shimo-Meguro, Meguro-ku,
Tokyo 153-0064, Japan Information in this document is provided solely to enable system and
0120 191014 or +81 3 5437 9125 software implementers to use Freescale Semiconductor products. There are
support.japan@freescale.com no express or implied copyright licenses granted hereunder to design or
fabricate any integrated circuits or integrated circuits based on the
information in this document.
Asia/Pacific:
Freescale Semiconductor Hong Kong Ltd.
Technical Information Center Freescale Semiconductor reserves the right to make changes without further
notice to any products herein. Freescale Semiconductor makes no warranty,
2 Dai King Street
representation or guarantee regarding the suitability of its products for any
Tai Po Industrial Estate particular purpose, nor does Freescale Semiconductor assume any liability
Tai Po, N.T., Hong Kong arising out of the application or use of any product or circuit, and specifically
+800 2666 8080 disclaims any and all liability, including without limitation consequential or
support.asia@freescale.com incidental damages. “Typical” parameters that may be provided in Freescale
Semiconductor data sheets and/or specifications can and do vary in different
For Literature Requests Only: applications and actual performance may vary over time. All operating
Freescale Semiconductor Literature Distribution Center parameters, including “Typicals”, must be validated for each customer
application by customer’s technical experts. Freescale Semiconductor does
P.O. Box 5405
not convey any license under its patent rights nor the rights of others.
Denver, Colorado 80217 Freescale Semiconductor products are not designed, intended, or authorized
1-800-441-2447 or 303-675-2140 for use as components in systems intended for surgical implant into the body,
Fax: 303-675-2150 or other applications intended to support or sustain life, or for any other
LDCForFreescaleSemiconductor@hibbertgroup.com application in which the failure of the Freescale Semiconductor product could
create a situation where personal injury or death may occur. Should Buyer
purchase or use Freescale Semiconductor products for any such unintended
or unauthorized application, Buyer shall indemnify and hold Freescale
Semiconductor and its officers, employees, subsidiaries, affiliates, and
distributors harmless against all claims, costs, damages, and expenses, and
reasonable attorney fees arising out of, directly or indirectly, any claim of
personal injury or death associated with such unintended or unauthorized
use, even if such claim alleges that Freescale Semiconductor was negligent
regarding the design or manufacture of the part.
AN1935
Rev. 1
11/2005