Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
4
Добавлен:
18.07.2023
Размер:
8.82 Mб
Скачать

Figure 27-1. Block Diagram

I/O PORT 0

DEVICE BOUNDARY

 

 

 

 

 

BOUNDARY SCAN CHAIN

 

 

TDI

 

 

JTAG PROGRAMMING

 

 

 

 

TDO

TAP

 

 

 

 

 

 

INTERFACE

 

 

 

 

TCK

 

 

 

 

 

CONTROLLER

 

 

 

 

 

 

 

TMS

 

 

 

 

 

 

 

 

 

 

 

 

 

INTERNAL

AVR CPU

 

 

 

 

 

FLASH

Address

 

 

 

 

 

 

SCAN

PC

 

 

 

 

INSTRUCTION

MEMORY

Data

 

 

 

 

CHAIN

Instruction

 

 

 

 

REGISTER

 

 

 

 

 

 

 

 

 

 

 

 

 

 

ID

 

 

 

 

 

 

 

 

REGISTER

BREAKPOINT

 

 

 

 

 

M

 

UNIT

 

FLOW CONTROL

 

 

 

 

BYPASS

 

 

 

 

 

 

U

 

 

UNIT

 

 

 

 

REGISTER

 

 

DIGITAL

 

 

 

X

 

 

 

ANALOG

 

 

 

 

 

 

 

 

 

 

 

 

 

PERIPHERAL

Analog inputs

 

 

 

 

 

 

PERIPHERIAL

 

 

 

 

 

 

UNITS

 

 

 

 

 

 

 

UNITS

 

 

 

 

 

 

 

 

 

 

 

BREAKPOINT

 

 

 

 

 

 

 

 

SCAN CHAIN

 

 

 

 

 

 

 

 

 

 

 

 

JTAG / AVR CORE

 

 

 

 

ADDRESS

 

 

 

COMMUNICATION

 

 

 

 

OCD STATUS

 

INTERFACE

 

 

 

 

DECODER

 

 

 

 

 

 

 

 

 

 

 

 

AND CONTROL

 

 

 

 

 

 

 

 

 

 

 

 

Control & Clock lines

 

 

 

 

 

I/O PORT n

 

 

 

27.3TAP - Test Access Port

The JTAG interface is accessed through four of the AVR’s pins. In JTAG terminology, these pins constitute the Test Access Port – TAP. These pins are:

TMS: Test mode select. This pin is used for navigating through the TAP-controller state machine

TCK: Test Clock. JTAG operation is synchronous to TCK

TDI: Test Data In. Serial input data to be shifted in to the Instruction Register or Data Register (Scan Chains)

TDO: Test Data Out. Serial output data from Instruction Register or Data Register

The IEEE std. 1149.1 also specifies an optional TAP signal; TRST – Test ReSeT – which is not provided.

When the JTAGEN Fuse is unprogrammed, these four TAP pins are normal port pins, and the TAP controller is in reset. When programmed, the input TAP signals are internally pulled high and the JTAG is enabled for Boundaryscan and programming. The device is shipped with this fuse programmed.

For the On-chip Debug system, in addition to the JTAG interface pins, the RESET pin is monitored by the debugger to be able to detect external reset sources. The debugger can also pull the RESET pin low to reset the whole system, assuming only open collectors on the reset line are used in the application.

ATmega640/V-1280/V-1281/V-2560/V-2561/V [DATASHEET]

290

2549Q–AVR–02/2014

Figure 27-2. TAP Controller State Diagram

1

Test-Logic-Reset

 

 

 

 

 

 

 

 

 

 

0

 

 

 

 

 

 

 

 

 

0

Run-Test/Idle

1

 

Select-DR Scan

1

 

Select-IR Scan

1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0

 

 

 

0

 

 

 

 

 

1

Capture-DR

 

 

1

Capture-IR

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0

 

 

 

0

 

 

 

 

 

 

Shift-DR

 

0

 

Shift-IR

 

0

 

 

 

 

1

 

 

 

1

 

 

 

 

 

 

Exit1-DR

 

1

 

Exit1-IR

 

1

 

 

 

 

 

 

 

 

 

 

 

 

 

0

 

 

 

0

 

 

 

 

 

 

Pause-DR

 

0

 

Pause-IR

 

0

 

 

 

 

1

 

 

 

1

 

 

 

 

 

0

Exit2-DR

 

 

0

Exit2-IR

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1

 

 

 

1

 

 

 

 

 

 

Update-DR

 

 

 

Update-IR

 

 

 

 

 

 

1

0

 

 

1

0

 

27.3.1TAP Controller

The TAP controller is a 16-state finite state machine that controls the operation of the Boundary-scan circuitry, JTAG programming circuitry, or On-chip Debug system. The state transitions depicted in Figure 27-2 depend on the signal present on TMS (shown adjacent to each state transition) at the time of the rising edge at TCK. The initial state after a Power-on Reset is Test-Logic-Reset.

As a definition in this document, the LSB is shifted in and out first for all Shift Registers.

Assuming Run-Test/Idle is the present state, a typical scenario for using the JTAG interface is:

At the TMS input, apply the sequence 1, 1, 0, 0 at the rising edges of TCK to enter the Shift Instruction Register

– Shift-IR state. While in this state, shift the four bits of the JTAG instructions into the JTAG Instruction Register from the TDI input at the rising edge of TCK. The TMS input must be held low during input of the 3 LSBs in order to remain in the Shift-IR state. The MSB of the instruction is shifted in when this state is left by setting TMS high. While the instruction is shifted in from the TDI pin, the captured IR-state 0x01 is shifted out on the TDO pin. The JTAG Instruction selects a particular Data Register as path between TDI and TDO and controls the circuitry surrounding the selected Data Register.

Apply the TMS sequence 1, 1, 0 to re-enter the Run-Test/Idle state. The instruction is latched onto the parallel output from the Shift Register path in the Update-IR state. The Exit-IR, Pause-IR, and Exit2-IR states are only used for navigating the state machine.

ATmega640/V-1280/V-1281/V-2560/V-2561/V [DATASHEET]

291

2549Q–AVR–02/2014

At the TMS input, apply the sequence 1, 0, 0 at the rising edges of TCK to enter the Shift Data Register – ShiftDR state. While in this state, upload the selected Data Register (selected by the present JTAG instruction in the JTAG Instruction Register) from the TDI input at the rising edge of TCK. In order to remain in the Shift-DR state, the TMS input must be held low during input of all bits except the MSB. The MSB of the data is shifted in when this state is left by setting TMS high. While the Data Register is shifted in from the TDI pin, the parallel inputs to the Data Register captured in the Capture-DR state is shifted out on the TDO pin.

Apply the TMS sequence 1, 1, 0 to re-enter the Run-Test/Idle state. If the selected Data Register has a latched parallel-output, the latching takes place in the Update-DR state. The Exit-DR, Pause-DR, and Exit2-DR states are only used for navigating the state machine.

As shown in the state diagram, the Run-Test/Idle state need not be entered between selecting JTAG instruction and using Data Registers, and some JTAG instructions may select certain functions to be performed in the RunTest/Idle, making it unsuitable as an Idle state.

Note:

Independent of the initial state of the TAP Controller, the Test-Logic-Reset state can always be entered by holding TMS

 

high for five TCK clock periods.

For detailed information on the JTAG specification, refer to the literature listed in “Bibliography” on page 294.

27.4Using the Boundary-scan Chain

A complete description of the Boundary-scan capabilities are given in the section “IEEE 1149.1 (JTAG) Boundaryscan” on page 295.

27.5Using the On-chip Debug System

As shown in Figure 27-1 on page 290, the hardware support for On-chip Debugging consists mainly of:

A scan chain on the interface between the internal AVR CPU and the internal peripheral units

Break Point unit

Communication interface between the CPU and JTAG system

All read or modify/write operations needed for implementing the Debugger are done by applying AVR instructions via the internal AVR CPU Scan Chain. The CPU sends the result to an I/O memory mapped location which is part of the communication interface between the CPU and the JTAG system.

The Break Point Unit implements Break on Change of Program Flow, Single Step Break, two Program Memory Break Points, and two combined Break Points. Together, the four Break Points can be configured as either:

4 single Program Memory Break Points

3 Single Program Memory Break Point + 1 single Data Memory Break Point

2 single Program Memory Break Points + 2 single Data Memory Break Points

2 single Program Memory Break Points + 1 Program Memory Break Point with mask (“range Break Point”)

2 single Program Memory Break Points + 1 Data Memory Break Point with mask (“range Break Point”)

A debugger, like the AVR Studio, may however use one or more of these resources for its internal purpose, leaving less flexibility to the end-user.

A list of the On-chip Debug specific JTAG instructions is given in “On-chip Debug Specific JTAG Instructions” on page 293.

The JTAGEN Fuse must be programmed to enable the JTAG Test Access Port. In addition, the OCDEN Fuse must be programmed and no Lock bits must be set for the On-chip debug system to work. As a security feature, the Onchip debug system is disabled when either of the LB1 or LB2 Lock bits are set. Otherwise, the On-chip debug system would have provided a back-door into a secured device.

The AVR Studio® enables the user to fully control execution of programs on an AVR device with On-chip Debug capability, AVR In-Circuit Emulator, or the built-in AVR Instruction Set Simulator. AVR Studio supports source level

ATmega640/V-1280/V-1281/V-2560/V-2561/V [DATASHEET]

292

2549Q–AVR–02/2014