Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Introduction to microcontrollers (G. Gridling, 2006).pdf
Скачиваний:
223
Добавлен:
12.08.2013
Размер:
1.64 Mб
Скачать

3.4. EXERCISES

87

If you are implementing this in a bit-banging solution, do not forget that after setting SCL to high (by setting the pin to input), you must wait for the rising edge on SCL before you can start the timer that will set SCL to low again.

3.3.3Multi-Master Mode

For a multi-master system to work, we need some means to control bus access and to synchronize the multiple clock signals. The IIC bus specification utilizes the wired-AND property of the SDA and SCL lines to achieve these goals.

Let us look at SCL first: Assume that initially, each master generates its clock signal independently of the other masters and puts it on SCL. Due to the wired-AND property, the first master to generate a falling edge will set SCL to low. Since the masters read back the actual value of SCL, as described in Section 3.3.2, and start timing a low or high phase only after the corresponding edge has been detected on SCL, the first falling edge on SCL triggers timing of the low phase on all masters. Now one by one, the masters will finish their low phases and try to set SCL to high. However, as long as one master still remains low, the SCL line stays low due to the wired-AND property. Hence, the master with the longest low phase generates the low phase of the resulting SCL signal. When this master goes high, the SCL signal rises to high and all masters start timing their high phases. Here, the first master to finish its high phase will set SCL to low again, effectively ending the SCL high phase. Hence, the master with the shortest high phase generates the high phase of the resulting SCL signal.

Bus arbitration uses the wired-AND property of the SDA line. When the bus is idle, any master can generate the start condition and begin to transmit the slave address. Like with the SCL line, the master reads back the SDA line to check whether the bit it has written has actually made it to SDA. Again, a low level will be dominant, so a master who writes a 1 and reads back a 0 recognizes that another master is using the bus as well and stops transmitting. In the end, only one master will remain (except if two masters have sent exactly the same message, in which case backing off is not necessary).

3.3.4Extended Addresses

As we have already mentioned, the original 7-bit addressing scheme was later extended to 10-bit addresses. To allow compatibility with the original 7-bit addressing, one of the reserved 7-bit addresses (11110XX)2 was used to implement 10-bit addressing:

To write to a slave, the master sends (11110XX)2 in the address field and sets R/W to 0. The XX in the field are the two most significant bits of the 10-bit slave address. Each slave compares these two bits to the msb’s of its own address and acknowledges if there is a match. The master now sends the remaining 8 bits of the address in the next byte. Only one of the previously addressed slaves will find a match and acknowledge. After that, the master transmits data to the slave.

To read from a slave, the master first sends (11110XX)2 and sets R/W to 0. It then sends the low byte of the address and waits again for the acknowledge. After the acknowledge, the master generates a repeated start condition and again sends (11110XX)2, but this time sets R/W to 1. The slave that was addressed last will react to the match of the two msb’s and will start transmitting in the next byte.

3.4 Exercises

Exercise 3.1 Explain the differences between synchronous and asynchronous communication. Can

88

CHAPTER 3. COMMUNICATION INTERFACES

you come up with a protocol that has both synchronous and asynchronous properties?

Exercise 3.2 Assume you have a UART frame format of 8E1. What percentage of the bandwidth is used for data, what is used up by the frame itself?

Exercise 3.3 Adapt equations (3.3)-(3.6) to account for e erroneous samples per bit. Remember: svn−e and svn+e now both have to be within bit k. How can you use your new formulas to account for an even s?

Exercise 3.4 You use the SPI to communicate with a peripheral device. What percentage of the bandwidth is used for data, what is used up by the communication frame itself?

Exercise 3.5 You use the IIC bus to transmit one byte of data to a slave. What percentage of the bandwidth is used for data, what is used up by the communication frame itself?

Exercise 3.6 We explained how the IIC bus synchronizes the clock signals of multiple slaves. How problematic is it that the resulting clock signal inherits the shortest high phase?

Exercise 3.7 How does the 10-bit addressing feature of the IIC bus affect 7-bit address devices?

Appendix A

Table of Acronyms

A

 

AC

Alternating Current (Wechselstrom)

AD

Analog/Digital

ADC

Analog/Digital Converter (Analog/Digital-Wandler)

ALU

Arithmetic-Logic Unit

B

 

BDLC

Byte Data Link Control

BDM

Background Debug Mode

BOR

Brown-Out Reset

bps

bits per second

C

 

CAN

Controller Area Network (Bus)

CC

Condition Code (Register)

CISC

Complex Instruction Set Computer

CLCC

Ceramic Leaded Chip Carrier (casing, Gehauseform)¨

COP

Computer Operates Properly

CPU

Central Processing Unit (Zentrale Recheneinheit)

CQFP

Ceramic Quad Flat Pack (casing, Gehauseform)¨

D

 

DA

Digital/Analog

DAC

Digital/Analog Converter (Digital/Analog-Wandler)

DC

Direct Current (Gleichstrom)

DDR

Data Direction Register

DIL

Dual In Line (casing, Gehauseform)¨

DIP

Dual-In-line Package (casing, Gehauseform,¨ same as DIL)

DMA

Direct Memory Access

DNL

Differential Non-Linearity (ADC)

DP

Dot Point (Dezimalpunkt)

DRAM

Dynamic RAM

DSP

Digital Signal Processor

DUT

Device Under Test

89

90

APPENDIX A. TABLE OF ACRONYMS

E

 

EEPROM

Electrically Erasable and Programmable ROM

EMC

Electromagnetic Compatibility (Elektromagnetische Vertraglichkeit,¨ EMV)

EMI

Electromagnetic Interference (Elektromagnetische Beeinflussung, EMB)

EMR

Electro-Mechanical Relay

EPROM

Erasable and Programmable ROM

ESD

Electrostatic Discharge (Elektrostatische Entladung)

F

 

FPGA

Field Programmable Gate Array

I

 

I2C

Inter-Integrated Circuit (bus)

ICD

In-Circuit Debugger

ICE

In-Circuit Emulator

ICSP

In-Circuit Serial Programming

IDE

Integrated Development Environment

IE

Interrupt Enable (Bit)

IF

Interrupt Flag (Bit)

IIC

see I2C

INL

Integral Non-Linearity (ADC)

IR

Infrared; Instruction Register

IRQ

Interrupt Request

ISP

In-System Serial Programming (programming interface)

ISR

Interrupt Service Routine

ISS

Instruction Set Simulator

J

 

JTAG

Joint Test Action Group (debug interface)

L

 

LED

Light Emitting Diode (Leuchtdiode)

LOC

Lines of Code

LQFP

Low Profile Quad Plastic Flat Back (casing, Gehauseform)¨

LSB

Least Significant Bit

M

 

MCU

Microcontroller Unit

MISO

Master In, Slave Out (part of SPI)

MMU

Memory Management Uni

MOSI

Master Out, Slave In (part of SPI)

MSB

Most Significant Bit

MSCAN

Motorola Scalable CAN

N

 

NMI

Non-Maskable Interrupt

NRZ

Non Return to Zero (encoding)

91

NVRAM

Non-Volatile RAM

O

 

OnCE

On-Chip Emulation (debug interface)

OTP

One-Time Programmable

P

 

PC

Program Counter

PCS

Peripheral Chip Select (part of SPI)

PCB

Printed Circuit Board

PDIP

Plastic Dual-In-Line Package (casing, Gehauseform)¨

PIN

Port Input Register (digital I/O)

PLCC

Plastic Leaded Chip Carrier (casing, Gehauseform)¨

PROM

Programmable ROM

PWM

Pulse Width Modulation (Pulsbreitenmodulation)

POR

Power-On Reset

ppm

Parts Per Million

pps

Pulses Per Second

Q

Quad Plastic Flat Back (casing, Gehauseform)¨

QFP

R

 

RAM

Random Access Memory

RISC

Reduced Instruction Set Computer

ROM

Read-Only Memory

rpm

Revolutions Per Minute (DC Motor, Umdrehungen pro Minute)

RTC

Real-Time Clock (Echtzeituhr)

S

 

SAR

Successive Approximation Register

SCI

Serial Communications Interface

SCL

Serial Clock Line (part of IIC)

SCK

System Clock (part of SPI)

SDA

Serial Data Line (part of IIC)

SDI

Serial Debug Interface

SO

Small Outline (casing, Gehauseform)¨

SP

Stack Pointer

SPI

Serial Peripheral Interface

SS

Slave Select (part of SPI)

SSP

Synchronous Serial Port

SSR

Solid State Relay

SRAM

Static RAM

T

 

TCK

Test Clock (JTAG)

TDI

Test Data In (JTAG)

92

APPENDIX A. TABLE OF ACRONYMS

TDO

Test Data Out (JTAG)

TMS

Test Mode Select (JTAG)

TQFP

Thin Quad Plastic Flat Back (casing, Gehauseform)¨

TWI

Two-wire Serial Interface (Atmel’s name for IIC)

U

 

UART

Universal Asynchronous Receiver/Transmitter

USART

Universal Synchronous/Asynchronous Receiver/Transmitter

V

Very Small Outline (casing, Gehauseform)¨

VSO

W

 

WCET

Worst-Case Execution Time