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

21.4.Physical Layer of Tiny Programming Interface

The TPI physical layer handles the basic low-level serial communication. The TPI physical layer uses a bi-directional, half-duplex serial receiver and transmitter. The physical layer includes serial-to-parallel and parallel-to-serial data conversion, start-of-frame detection, frame error detection, parity error detection, parity generation and collision detection.

The TPI is accessed via three pins, as follows:

RESET: Tiny Programming Interface enable input

TPICLK: Tiny Programming Interface clock input

TPIDATA: Tiny Programming Interface data input/output

In addition, the VCC and GND pins must be connected between the external programmer and the device.

21.4.1.Enabling

The following sequence enables the Tiny Programming Interface:

Apply 5V between VCC and GND

Depending on the method of reset to be used:

Either: wait tTOUT (see System and Reset Characteristics) and then set the RESET pin low. This will reset the device and enable the TPI physical layer. The RESET pin must then be kept low for the entire programming session

Or: if the RSTDISBL configuration bit has been programmed, apply 12V to the RESET pin. The RESET pin must be kept at 12V for the entire programming session

Wait tRST (see System and Reset Characteristics )

Keep the TPIDATA pin high for 16 TPICLK cycles

Figure 21-2. Sequence for enabling the Tiny Programming Interface

t RST

16 x TPICLK CYCLES

RESET

TPICLK

TPIDATA

Related Links

System and Reset Characteristics on page 214

21.4.2.Disabling

Provided that the NVM enable bit has been cleared, the TPI is automatically disabled if the RESET pin is released to inactive high state or, alternatively, if VHV is no longer applied to the RESET pin.

If the NVM enable bit is not cleared a power down is required to exit TPI programming mode. See NVMEN bit in TPISR – Tiny Programming Interface Status Register.

Related Links

TPISR on page 209

21.4.3.Frame Format

The TPI physical layer supports a fixed frame format. A frame consists of one character, eight bits in length, and one start bit, a parity bit and two stop bits. Data is transferred with the least significant bit first.

Atmel ATtiny102 / ATtiny104 [DATASHEET] 199

Atmel-42505D-ATtiny102-ATtiny104_Datasheet_Complete-10/2016

Figure 21-3. Serial frame format.

TPICLK

TPIDATA

IDLE

ST

D0

D1

D7

P

SP1

SP2

IDLE/ST

Symbols used in the above figure:

ST: Start bit (always low)

D0-D7: Data bits (least significant bit sent first)

P: Parity bit (using even parity)

SP1: Stop bit 1 (always high)

SP2: Stop bit 2 (always high)

21.4.4.Parity Bit Calculation

The parity bit is always calculated using even parity. The value of the bit is calculated by doing an

=

0

1

2

3

4

5

6

7

0

exclusive-or of all the data bits, as follows:

 

 

 

where:

P: Parity bit using even parity

D0-D7: Data bits of the character

21.4.5.Supported Characters

The BREAK character is equal to a 12 bit long low level. It can be extended beyond a bit-length of 12.

Figure 21-4. Supported characters.

 

 

 

 

 

DATA CHARACTER

 

 

 

 

TPIDATA

IDLE

ST

D0

D1

D7

P

SP1

SP2

IDLE/ST

 

 

 

 

 

BREAK CHARACTER

 

 

 

 

TPIDATA

IDLE

 

 

 

 

 

 

 

IDLE/ST

21.4.6.Operation

The TPI physical layer operates synchronously on the TPICLK provided by the external programmer. The dependency between the clock edges and data sampling or data change is shown in the figure below. Data is changed at falling edges and sampled at rising edges.

Atmel ATtiny102 / ATtiny104 [DATASHEET] 200

Atmel-42505D-ATtiny102-ATtiny104_Datasheet_Complete-10/2016

Figure 21-5. Data changing and Data sampling.

TPICLK

TPIDATA

SAMPLE

SETUP

The TPI physical layer supports two modes of operation: Transmit and Receive. By default, the layer is in Receive mode, waiting for a start bit. The mode of operation is controlled by the access layer.

21.4.7.Serial Data Reception

When the TPI physical layer is in receive mode, data reception is started as soon as a start bit has been detected. Each bit that follows the start bit will be sampled at the rising edge of the TPICLK and shifted into the shift register until the second stop bit has been received. When the complete frame is present in the shift register the received data will be available for the TPI access layer.

There are three possible exceptions in the receive mode: frame error, parity error and break detection. All these exceptions are signalized to the TPI access layer, which then enters the error state and puts the TPI physical layer into receive mode, waiting for a BREAK character.

Frame Error Exception. The frame error exception indicates the state of the stop bit. The frame error exception is set if the stop bit was read as zero.

Parity Error Exception. The parity of the data bits is calculated during the frame reception. After the frame is received completely, the result is compared with the parity bit of the frame. If the comparison fails the parity error exception is signalized.

Break Detection Exception. The Break detection exception is given when a complete frame of all zeros has been received.

21.4.8.Serial Data Transmission

When the TPI physical layer is ready to send a new frame it initiates data transmission by loading the shift register with the data to be transmitted. When the shift register has been loaded with new data, the transmitter shifts one complete frame out on the TPIDATA line at the transfer rate given by TPICLK.

If a collision is detected during transmission, the output driver is disabled. The TPI access layer enters the error state and the TPI physical layer is put into receive mode, waiting for a BREAK character.

21.4.9.Collision Detection Exception

The TPI physical layer uses one bi-directional data line for both data reception and transmission. A possible drive contention may occur, if the external programmer and the TPI physical layer drive the TPIDATA line simultaneously. In order to reduce the effect of the drive contention, a collision detection mechanism is supported. The collision detection is based on the way the TPI physical layer drives the TPIDATA line.

The TPIDATA line is driven by a tri-state, push-pull driver with internal pull-up. The output driver is always enabled when a logical zero is sent. When sending successive logical ones, the output is only driven actively during the first clock cycle. After this, the output driver is automatically tri-stated and the TPIDATA line is kept high by the internal pull-up. The output is re-enabled, when the next logical zero is sent.

Atmel ATtiny102 / ATtiny104 [DATASHEET] 201

Atmel-42505D-ATtiny102-ATtiny104_Datasheet_Complete-10/2016