• Sonuç bulunamadı

AN EMBEDDED 12C BUS lVIONITORING SYSTEM DESIGN IMPLEMENT ATI ON

N/A
N/A
Protected

Academic year: 2021

Share "AN EMBEDDED 12C BUS lVIONITORING SYSTEM DESIGN IMPLEMENT ATI ON"

Copied!
4
0
0

Yükleniyor.... (view fulltext now)

Tam metin

(1)

SAU Fen Bılımleri Enstitüsü Dergisi 6.Cilt, 3.Sayı (Eylül 2002)

An Embedded rıc Bus i\1onitoring Y em Desina lmplemantatiın o .. S.Atmac:ı" .1�.0uerit

AN EMBEDDED 12C BUS lVIONITORING SYSTEM DESIGN

IMPLEMENT ATI ON

Sedat ATMACA, A.Tnran ÖZCERIT

A bstract

- In this article, hardware b as ed, s tand

al one

1

OOKbit/s speed 12C bu s otonit or is carried Jut.

12C traffic is logged to the local on-board memory. With the help of hard and sofnyare filter the stored

messaget: �an be limited to the i nteresting ones.

All bus activity including start/stop events, slave addresses, read/wı jte requests, acknowledgments, and data aı·e displayed in computer.

Index Terms - l2C bus, I2C bus controller, serial buses, bus monitoring,

••

Ozet

- Bu çalışmada, donanım tabanlı lOOKbit/sn hızında I2C monitor yapılmıştır.

I2C-Bus'taki veriler, sistemdeki dahili hafızava .J

kaydedilerek bilgisayarın seri portundan gönderilir. Sistem kullanıcıya Bus'taki

START,

STOP, Yönetilen-adres, veri, oku/yaz ve kabul bilgilerinin durumu hakkında bilgi verir.

Anahtar Kelimeler- I2C bus, 12C bus denetleyicisi, serial bu s 'lar, bu s görüntüleme.

I. INTRODUCTION

The

I2C-bus

is a protocol which su

pports

the conımunication of the various chips in embedded systems or portab le devices.

This article explains software

and

hardware specification for monitoring an I2C-bus \Vith the standard 80c51 microcontroller. The I2C-bus monitor block diagram is illustrated in Figure

2.

The PCF8584 is

a controller

which can listen t o I2C-bus. This chip can

be

used to listen and

monitor

the actual data on the

rıc-bus.

It is illush·ated in

F

igu

r

e

3.

Seda: Atmaca, Sakaıya University, Institute of Sc:ence3, Sakaıya, sedatatmaca@hotn'ai l.coın

A.Turan Özcerit, Sakarya Unıversity, Technical Educat!or. Faculty,

Sakarya. aozcerı t@sakarya. ed u. tr

124

It provides what is going on the I2C-bus. It

has

several

internal

register

to

teli it wlıat to do

and

ho·�,

to

act up on the I2C-bus line. The 80c5 I sends

control

and data bytes to control the PCF8584 in monitor mode.

F

igure

4

shows us I2C-bus rnonitor

flo\vchart with the

PCF8584.

II. THE

12C BUS CONCEPT

The

ec

bus isa simple bidirectional

two-wire

ınter

f

ace that provides for effıcient Inter-IC control. The function of these devices range from EEPROYls to LCD drivers.

[

!

]

Two

wires,

serial

d

at

a

(SDA)

and serial clock (SCL)

can·y information between the devices connected to the bus. In order to distinguish betvveen devices on the bus, each device is recognized by a unjque address ( v.'hether

. ' .

ıt s a mıcro-controller, LCD driver, memory

or

keyboard interface) and can opera te as eitber a transmitter or receiver, depending on the function of the devices. Obviously an LCD driver is onlv a receiver, w

b

e

r

eas a men1ory can both receive �and transmit data. In a

d

diton to transmitters and receivers, devices

c

an also be considered as masters

or s]a\·es

when performing data transfers.

The I2C-bus is a multi-master bus. This means

tlıat

more than one devices capable of controlling

the bus

can be co

n

nected to it. As masters are usually

micro­

contro1lers,

l

et's consider the case of a data transfer between two micro-controllers connected to the bus.(2] Both

SDA

and

SCL

are bi-directional lines. When the bus is free, both lines a re high. Devices are capable of

clan1ping and re leasing the wires. If one of the devices connec te

d

to the bu s clamps a line, this line \�.rili

become low and only if devices have released a

l

ine, it

will become high again.

The

fC-bus protocol uses two wires for

corrnnunication. One is the data line (SDA) and one is the synchron1zation line (SCL). The

data

is transmitted in packets of 8 bits (one bytes), followed by an acknowledgement bit from the receiver.

For

the entire message

a

fe,v extra bits are added to

ind

icate

start

(2)

SAl.. Fen Bilimleri Enstitüsü Dergisi 6.Ci 't.

3.Sayı (Eylül 2002)

START addressing e . g.RE..iı..ı. D S, ., . . ... ", . ,. -; ... , t.: •• •.ı � ' ' . .

- ·

sıa

. .

v�A

:1

tifi

���s-

;

·

· �

. .. .. : .. t.;..f"i-.·

'

...

:

,

from tnaster to slave

1

'

;

A

\�

1

data trans:rnüı sion +

acknow1edge

Data

byte

r

Repeated ..

An Embedded 12C Rus Monitoring Systenı

Desing lmplemantatiın S.Atmaca, A.T.

Ö

zcerit

STOP

'"

A

�, ,!,; � .

. . ·1

-A'

-t

-. J? ..

1

J

froın slave to master

Figure I.

fe

bus protocol

conditions and s top con

di

t

i

ons. Those conditions te ll

other

devices

whether the

bus is currentl

y

in use or not.

The

protJcol also provides a simple but e

f

fective

means

to

handie

data collision. Data colhsion is a stat

e

where in

data is blurred

becausc

more devices

t

ry to

1

_

.�ısmit bytes at the same

tiıne.

In

F

ig

ure

1

a possible message is

illustrated. T

h

e

n1essage

is

initialized by a d

e

vic

e

acting as a

master.

The devirF�

one n1eant to respond acts as a slave.

The

message

b

e

g

i

ns

with

a

START

condi

ti

o

n followed by t

h

e address of the slz. re devices.

If anything

goes

\Vrong, the

r

e

ce

i

v

j

ng

device

is

busy

domg

something

else, it can always respond with no

acknowledgement. The ma

s

ter stops the transrnission

and

ınay

try la

ter. [3]

. . . .

fe

l'vt orlııle SDA SCL

connected to the 8-bit data bus of a rnicroprocessor,

to

g

ether

with the

bus control hnes. The interface and

connections for the

PCF8584

are

shovvn in

Figure

3

i

n

detai1.

This

IC is

a powerful and versatile means of providing

I2C conununications for an embcdded system.

This chip

has

a certain ınode in which

it does

no

t

take

part in the real

PC communication

but o

n

ly

records

what is

going on. It listens to all addresses, but does not

g

e

ner

a

t

e any acknowledge.

A

u

n

i

versa

1 PC

data logger system

has

been built using

some software routines and a

MCU.

The

P

C

F8

5

8

4

is used

to

interface

b

e

tween paraUel

m

icroproces

s

or or microcontroller buses and the serial

ııc-bus.

On

the PC-b

us, it

can act either

as a master or

a slave. Bi-directional data

transfer bet\veen

the PC-bus

I2C Sus Monitor PC Serial Pnrt Log File

Figure 2. 12C Bus connection diagram

III. 12C

BUS MONITORING SYSTEM

The

fe

bus

n1onitor system

b

l

oc

k

diagram is

illustrated

in Fi

gure

2. It

can be

de

s

i

gne

d

in several

ways.

O

ne of

them

is so

f

tware oriented, anather is

hardware

or

i

ented. In this study,

I2C b

us is n1onitored

\\'ith h

a rdwar

e

oriented I2C

bus control

J

er namely

PCF8584.

The PCF8584 is a device that can be

125

and t

h

e parallel-bus of a microcontroller is carried out

on

a

byte-wise basıs, using either an intenupt or polled

(3)

SAU Fen Bilimlerı Enstıtüsü Dergisi 6.Cilt, J.Sayı (Eylül 2002)

The PCF8584 has fıve internal register 1ocations. Three of the se ( own address register

SO', clock

register

S2

and intemıpt vector

S3)

are used for initialization of the PCF8584. Nonnally they are only written once

directly after reserting of the PCF8584.

In order to control PCF8584, the 8

0

c51 has been used \Vith an 8-bit control register and 8-bit status regist

e

r.

Those registers are located on the PCF'8584 and can be accessed via the same data lines that it is used to

transfer data. To choose between data to transceive and data to control the ch

i

p, a hardware line is required. This line is called A O.

PCF8584 status/control register is called S 1. This register 8-bit

wide

and 2-level in depth. The first lcvel

cons

i

s

ts of

eight write-only bits and it is the control

section. The second level consists of eiglıt read-only bits and it is the status sect

i

on.

,..ı he most. significant bit in the S 1 register is PIN

(Pending Interrupt Not). This bit can be read as vvell as

written.

Bus

traffic is monitored by the PIN bit, which

is reset to logic

O

after the ack.nowledge bit of an

incoming byte has bPen received, and is set to logic 1

as soon as the fist bit of the next

i

nconı

i

n g byte

is

detected. Reading the data buffer

SO

sets the PIN bit to

logic

1.

Data in the read buf

f

er is valid from PIN =

O

and during the next 8 clock pulses (un til next ac

lm

owledge ).

The second bit is

ESO

(Enable serial Output) and can

be used to switch the serial PC-interface on or off.

When the interface is shut off a few special control data can be programmed into the chip. Those data are

it

s own address (register

SO'

), an intenupt vector

(

register

3)

and

abit sequence to select internal and

FC

clock rates (register 2). When 7-bit own address register SO' is loade

d

with all zeros, the PC controller

acts as a passive PC monitor. To select one of those

special registers the ES 1 and

ES2

bits should be

programmed according to specifıcation. An external

interrupt output can be enabled with ENI and the

generation of

Start

and

Stop

conditions for serial

comınunications can be controlled by the ST A and

STO bits. W ith ACK the sending of acknowledges after each transmitted byte can be control1ed.

he

f

allawing bits can only be read and only use

d

in

systems mo

ni

tor:

• In monitor mode the controller is always in

Slave/Rcceiver mode.

• The controller never generates an acknowledge.

• The controller never generates an interrupt

request.

• A pending interrupt condition does not force

SCL

LOW.

• Receive

d data

is automatically transferred to the

read bu

ff

er. (5]

The

STS

bit tells us if someone generates a

Stop

cond

i

t

i

on on the

PC

bus. If

BER

becomes logic

true,

a

1 26

An Errıbedded 12C Bus :vfonitoring System Besing lmplemantathn S.Atmaca,

A.T.Öz(!erit

bus

eıTor

has been detected. Autoınatically

BB'

is reset

to 1

(

inaeti

ve) and PIN is set to

O

(

act

i

ve

)

.

The An other status bit

is LRB/ ADO,

'Last Received

Bit' or 'Address O

(

G

enera

l

Call) bit'. This status bit

serves a dual function, and is valid only while

PIN=

O;

F

irst,

LRB

holds the value of the

last received bit

over

the

f?

C-bus -w·hile AAS =

O

(no1 acidressed as slave).

N

ormally this w

ili

be the va

I

uc of the slave

acknowledgenıent; thus checking for slave

ackno\vledgement is done via testing or the

LRB.

Second,

�ADO;

\V hen AAS �

l

CAddressed As

S

la ve'

condition). the 12C-bus controller has

been

acidressed as

a slave. Under this condition, this bit beconıes the

'ADO' bit and will be set to log

i

c

1

if the s la ve

address

received \Vas the 'general call' (OOH) address, or logic

O if it was the I2C-bus controller's own sJave address.

1

lno

no

initlalizion of PCFB584

at monitor modc

read hyte from S1 register

ye s

read hyte from S1 register

no

Read Da

t

a

from

SO regs\ter

Write byte to

Memory

ye s

Figure 4.

fe

Bus monitor

yes Read Address from

SO register

(4)

SAU Fen Bilimleri Enstitüsü De:-gisı 6.Cilt, 3.Sayı (Eylül 2002)

Ncxt is

the AAS bit (Addressed As Slavc).

The

bit becomes active when the address signaled from the bus n1atches our chip 's address. AAS is set to logic 1 at

-PC

. ' .

.

-.

.

. . -o ·�-)

en

ro -.ı: -· �) -o o ;:::ı. co o ("')

Rx D

-.:ı.. uı

-<

--" n � o

AO

n o ::3 ,...,.

TxD

---c o -ro '"""t

12C-bus controller

\•Vit h pc F8584

An Embedded 12C Bus Monitoring Systenı

Desing Jmplemantatiın S.Atmaca, A.

T.Özcerit

12C-bus

c cı (ı

ı:·

l.-, L

ı_l ,H,. •..J '

Fıgure 3. The rıc ;vionıtor with PCF8584

every Start

cond1tıon, and reset at every 9th c

lo

ck pulse. The LAB J:l;t (Lost Arbitration) is set when another device has taken over master

. If

so, we loose

our control and

become

slave. Last bit in the status rcgister is BB '(Bus Busy, re verse logic). If O the bus is

currently in

use

and access can better

be

postponed.

But

if we want to

be

rascals we c

ou

ld just transmit

somc data bits- to tease the other devices that

try

to

communicatc.

IV.CONCLUSIONS

In this study I2C-bus mon

i

tor system listens and

monitors data

with

the help of PCF8584 hardware based I2C-bus controller, and the 80c5 1

microcontroller. It can be used for testing available signals on the I2C-bus and error conditions. Because

of

this, it can be used as test equipment in a digital

laboratory. l2C-bus acti

o

ns are logged to the on-board memory and the system designed

filters the

stored

messages that are limited to

the

interesting ones.

(?.C-bus n1onitor is ab le to operate at a 1 OOKhz clock speed. Because

the

average execution period for an

80c51 instruction is

12

cycles, the microcontroller

us ing a l l . 0592MHz clock can expect to average 1 �LS

per instruction.

It

appeared, that there \Vould be about

1

O instructions worth of execution time during a

normal I2C clock period. In order to monitor upon the

lOOKHz bus devices (400Khz), It would be necessary to enıploy one of the faster 805 1 s that nın at 40Mhz

clock speeds.

127

REFERENCES

[ 1] Jan1es,

M.Flynn, "u

nderstanding and Using the

I2C-Bus,>, Embedded System Progra

mınin

g

[2] Philips Serniconductors, "The ı-c-Bus ')

Specifıcation", Version

2.1, 2000

[3] Koetsier I-Iilbert, "Personal

Computer

interface to

12

C bus via parallel printer port using PCF8584 bus

controller,

System basics and Specification, 1999

[ 4] Philip s Semiconductors, "Interfacing the PCF8584

I2C-Bus

controller to 80c51 family microcontrollers",

1994

[5] Philips Se

nıi

con

d

uc

t

ors, "PCF8584 I2C-Bus

Referanslar

Benzer Belgeler

Başlangıçta resim ve minyatür üzerine çalışmaları bulu- nan Kale, çok ince çizgiler çizebildiği- ni fark ettiğinde daha ne kadar küçük çizgiler çizebileceğini

The Southern Africa Development Organization (SADC) is one such organization which was initially created as a countering block to the economic manipulation of apartheid south

•  Gums can be hydrolysed by prolonged boiling with dilute acids to yield a mixture of sugars (mainly galactose, arabinose, xylose) and uronic acids.. •  Gums are commonly found

Bu nedenle çalışmamızda, diz OA’li hastalarda dinamometre yardımı ile uygulanan ve diğer egzersizlere göre daha standardize olan izokinetik egzersiz programının,

Therefore, this research aims to provide an updated look at the theory of social production of space from a designerly perspective which offers a novel approach on everyday life

As the probability (π) that a gift is the officer’s most preferred choice increases, it is more likely that the dishonest client offers that gift as bribe and achieves his bribery

design of the bilobed flap with the use of two overlapping hearts. The defect is marked as circle, the first heart is marked pink, and the second heart is marked green. First half

Taiwan's hospital accreditation began in the Republic of China 60 years by the Ministry of Education, organized in conjunction with the Department of Health, the purpose of