Sie sind auf Seite 1von 24

APPLICATION

NOTE
AP-248
Septembei 1987
Using The 8096
IRA HORDEN
MCO APPLICATIONS FNOINFFR
Order Number 270061-002
Information in this document is provided in connection with Intel products Intel assumes no liability whatsoev-
er including infringement of any patent or copyright for sale and use of Intel products except as provided in
Intels Terms and Conditions of Sale for such products
Intel retains the right to make changes to these specifications at any time without notice Microcomputer
Products may have minor variations to this specification known as errata
Other brands and names are the property of their respective owners
Since publication of documents referenced in this document registration of the Pentium OverDrive and
iCOMP trademarks has been issued to Intel Corporation
Contact your local Intel sales office or your distributor to obtain the latest specifications before placing your
product order
Copies of documents which have an ordering number and are referenced in this document or other Intel
literature may be obtained from
Intel Corporation
PO Box 7641
Mt Prospect IL 60056-7641
or call 1-800-879-4683
COPYRIGHT INTEL CORPORATION 1996
Using The 8096
CONTENTS PAGE
10 INTRODUCTION 1
20 8096 OVERVIEW 1
21 General Description 1
211 CPU Section 2
212 IO Features 4
22 The Processor Section 4
221 Operations and Addressing
Modes 4
222 Assembly Language 7
223 Interrupts 8
23 On-Chip IO Section 10
231 TimerCounters 10
232 HSI 11
233 HSO 12
234 Serial Port 13
235 A to D Converter 16
236 PWM Register 17
30 BASIC SOFTWARE EXAMPLES 19
31 Using the 8096s Processing
Section 19
311 Table Interpolation 19
312 PLM-96 22
32 Using the IO Section 24
321 Using the HSI Unit 24
322 Using the HSO Unit 25
323 Using the Serial Port in
Mode 1 29
324 Using the A to D 31
40 ADVANCED SOFTWARE
EXAMPLES 31
41 Simultaneous IO Routines under
Interrupt Control 31
42 Software Serial Port Using the
HSIO Unit 34
43 Interfacing an Optical Encoder to
the HSI Unit 39
50 HARDWARE EXAMPLE 51
51 EPROM Only Minimum
System 51
52 Port Reconstruction 53
60 CONCLUSION 54
70 BIBLIOGRAPHY 54
CONTENTS PAGE
APPENDICES
Appendix A Basic Software
Examples A-1
A1 Table Lookup 1 A-1
A2 Table Lookup 2 A-3
A3 PLM-96 Code with Expansion A-5
A4 Pulse Measurement A-11
A5 Enchanced Pulse Measurement A-13
CONTENTS PAGE
A6 PWM Using the HSO A-15
A7 Serial Port A-19
A8 A to D Converter A-21
Appendix B HSO and A to D Under
Interrupt Control B-1
Appendix C Software Serial Port C-1
Appendix D Motor Control Program D-1
Figures
2-1 8096 Block Diagram 1
2-2 Memory Map 2
2-3 SFR Layout 3
2-4 Major IO Functions 4
2-5 Instruction Summary 5
2-6 Instruction Format 7
2-7 Interrupt Sources 8
2-8 Interrupt Vectors and Priorities 8
2-9 Interrupt Structure Block
Diagram 9
2-10 The PSW Register 10
2-11 HSI Unit Block Diagram 11
2-12 HSI Mode Register 11
2-13 HSO Command Register 12
2-14 HSO Block Diagram 12
2-15 Serial Port ControlStatus
Register 13
2-16 Baud Rate Formulas 14
2-17 Baud Rate Values for 10 11 12
MHz 15
2-18 Multiprocessor Communication 16
2-19 A to D ResultCommand
Register 17
2-20 PWM Output Waveforms 18
2-21 PWM to Analog Conversion
Circuitry 18
3-1 Using the HSIO to Monitor Rotating
Machinery 28
3-2 Serial Port Level Conversion 30
4-1 10-Bit Asynchronous Frame 35
4-2 Optical Encoder and Waveforms 39
4-3 Filtered Encoder Waveforms 40
4-4 Schematic of Optical Encoder to
8096 Interface 41
4-5 Motor Driver Circuitry 41
4-6 Mode State Diagram 44
4-7 Motor Control Modes 49
5-1 Minimum System Configuration 52
Listings
3-1 Include File DEMO96INC 19
3-2 ASM-96 Code for Table Lookup
Routine 1 20
3-3 ASM-96 Code for Table Lookup
Routine 1 21
3-4 PLM-96 Code for Table Lookup
Routine 1 23
3-5 32-Bit Result Multiply Procedure for
PLM-96 23
3-6 Measuring Pulses Using the HSI
Unit 24
3-7 Enhanced HSI Pulse Measurement
Routine 25
3-8 Generating a PWM with the HSO 26
3-9 Changes to Declarations for HSO
Routine 27
3-10 Driver Module for HSO PWM
Program 27
3-11 Using the Serial Port in Mode 1 29
3-12 Scanning the A to D Channels 31
4-1 Using Multiple IO Devices 32
4-2 Software Serial Port
Declarations 35
4-3 Software Serial Port Interface
Routines 36
4-4 Software Serial Port Initialization
Routine 36
4-5 Software Serial Port Transmit
Process 37
4-6 Receive Process 37
4-7 Motor Control HSO0 Timer
Routine 42
4-8 Motor Control HSI Data Available
Routine 44
4-9 Motor Control Mode 1 Routines 45
4-10 Motor Control Mode 0 Routines 46
4-11 Motor Control Software Timer 1
Routine 47
4-12 Motor Control Next Position
Lookup 49
4-13 Motor Control Timer Interrupt
Routine 50
4-14 Motor Control Software Timer
Interrupt Handler 50
4-15 Motor Control Software Timer 2
Routine 51
AP-248
10 INTRODUCTION
High speed digitaI signaIs aie fiequentIy encounteied in
modein contioI appIications. In addition, theie is often
a iequiiement foi high speed 16-bit and 32-bit piecision
in caIcuIations. The MCS-96 pioduct Iine, geneiicaIIy
iefeiied to as the 8096, is designed to be used in appIi-
cations which iequiie high speed caIcuIations and fast
I/O opeiations.
The 8096 is a 16-bit miciocontioIIei with dedicated
I/O subsystems and a compIete set of 16-bit aiithmetic
instiuctions incIuding muItipIy and divide opeiations.
This Ap-note wiII biiefIy desciibe the 8096 in section 2,
and then give shoit exampIes of how to use each of its
key featuies in section 3. The concIuding sections fea-
tuie a few exampIes which make use of seveiaI chip
featuies simuItaneousIy and some haidwaie connection
suggestions. Fuithei infoimation on the 8096 and its
use is avaiIabIe fiom the souices Iisted in the bibIiogia-
phy.
20 8096 OVERVIEW
21 General Description
UnIike miciopiocessois, miciocontioIIeis aie geneiaIIy
optimized foi specific appIications. InteIs 8048 was op-
timized foi geneiaI contioI tasks whiIe the 8051 was
optimized foi 8-bit math and singIe bit booIean opeia-
tions. The 8096 has been designed foi high speed/high
peifoimance contioI appIications. Because it has been
designed foi these appIications the 8096 aichitectuie is
diffeient fiom that of the 8048 oi 8051.
Theie aie two majoi sections of the 8096, the CPU
section and the I/O section. Fach of these sections can
be subdivided into functionaI bIocks as shown in Figuie
2-1.
2700611
Figure 2-1 8096 Block Diagram
1
AP-248
211 CPU SECTION
The CPU of the 8096 uses a 16-bit ALU which opeiates
on a 256-byte iegistei fiIe instead of an accumuIatoi.
Any of the Iocations in the iegistei fiIe can be used foi
souices oi destinations foi most of the instiuctions.
This is caIIed a iegistei to iegistei aichitectuie. Many
of the instiuctions can aIso use bytes oi woids fiom
anywheie in the 64K byte addiess space as opeiands. A
memoiy map is shown in Figuie 2-2.
In the Iowei 24 bytes of the iegistei fiIe aie the iegistei-
mapped I/O contioI Iocations, aIso caIIed SpeciaI
Function Registeis oi SFRs. These iegisteis aie used to
contioI the on-chip I/O featuies. The iemaining 232
bytes aie geneiaI puipose RAM, the uppei 16 of which
can be kept aIive using a Iow cuiient powei-down
mode.
2700612
Figure 2-2 Memory Map
2
AP-248
Figuie 2-3 shows the Iayout of the iegistei mapped
I/O. Some of these iegisteis seive two functions, one if
they aie iead fiom and anothei if they aie wiitten
to. Moie infoimation about the use of these iegisteis is
incIuded in the desciiption of the featuies which they
contioI.
2700613
Figure 2-3 SFR Layout
3
AP-248
212 IO FEATURES
Many of the I/O featuies on the 8096 aie designed to
opeiate with IittIe CPU inteivention. A Iist of the majoi
I/O functions is shown in Figuie 2-4. The Watchdog
Timei is an inteinaI timei which can be used to ieset
the system if the softwaie faiIs to opeiate piopeiIy. The
PuIse-Width-ModuIation (PWM) output can be used as
a iough D to A, a motoi diivei, oi foi many othei
puiposes. The A to D conveitei (ADC) has 8 muIti-
pIexed inputs and 10-bit iesoIution. The seiiaI poit has
seveiaI modes and its own baud iate geneiatoi. The
High Speed I/O section incIudes a 16-bit timei, a 16-bit
countei, a 4-input piogiammabIe edge detectoi, 4 soft-
waie timeis, and a 6-output piogiammabIe event genei-
atoi. AII of these featuies wiII be desciibed in section
2.3.
22 The Processor Section
221 OPERATIONS AND ADDRESSING MODES
The 8096 has 100 instiuctions, some of which opeiate
on bits, some on bytes, some on woids and some on
Iongs (doubIe woids). AII of the standaid IogicaI and
aiithmetic functions aie avaiIabIe foi both byte and
woid opeiations. Bit opeiations and Iong opeiations aie
piovided foi some instiuctions. Theie aie aIso fIag ma-
nipuIation instiuctions as weII as jump and caII instiuc-
tions. A fuII set of conditionaI jumps has been incIuded
to speed up testing foi vaiious conditions.
Bit opeiations aie piovided by the Jump Bit and Jump
Not Bit instiuctions, as weII as by immediate masking
of bytes. These bit opeiations can be peifoimed on any
of the bytes in the iegistei fiIe oi on any of the speciaI
function iegisteis. The fast bit manipuIation of the
SFRs can piovide iapid I/O opeiations.
A symmetiic set of byte and woid opeiations make up
the majoiity of the 8096 instiuction set. The assembIy
Ianguage foi the 8096 (ASM-96) uses a B suffix on a
mnemonic to indicate a byte opeiation, without this
suffix a woid opeiation is indicated. Many of these op-
eiations can have one, two oi thiee opeiands. An exam-
pIe of a one opeiand instiuction wouId be:
NOT Value1 Value1 e 1s complement (Value1)
A two opeiand instiuction wouId have the foim:
ADD Value2Value1 Value2 e Value2 a Value1
A thiee opeiand instiuction might Iook Iike:
MUL Value3Value2Value1
Value3 e Value2

Value1
The thiee opeiand instiuctions combined with the ieg-
istei to iegistei aichitectuie aImost eIiminate the neces-
sity of using tempoiaiy iegisteis. This iesuIts in a fastei
piocessing time than machines that have equivaIent in-
stiuction execution times, but use a standaid aichitec-
tuie.
Long (32-bit) opeiations incIude shifts, noimaIize, and
muItipIy and divide. The woid divide is a 32-bit by 16-
bit opeiation with a 16-bit quotient and 16-bit iemain-
dei. The woid muItipIy is a woid by woid muItipIy
with a Iong iesuIt. Both of these opeiations can be done
in eithei the signed oi unsigned mode. The diiect un-
signed modes of these instiuctions take onIy 6.5 micio-
seconds. A noimaIize instiuction and sticky bit fIag
have been incIuded in the instiuction set to piovide
haidwaie suppoit foi the softwaie fIoating point pack-
age (FPAL-96).
Major IO Functions
High Speed Input Unit Provides Automatic Recording of Events
High Speed Output Unit Provides Automatic Triggering of Events and Real-Time Interrupts
Pulse Width Modulation Output to Drive Motors or Analog Circuits
A to D Converter Provides Analog Input
Watchdog Timer Resets 8096 if a Malfunction Occurs
Serial Port Provides Synchronous or Asynchronous Link
Standard IO Lines Provide Interface to the External World when other Special Features
are not needed
Figure 2-4 Major IO Functions
4
AP-248
Mnemonic
Oper-
Operation (Note 1)
Flags
Notes
ands Z N C V VT ST
ADDADDB 2 D wD a A u
ADDADDB 3 D wB a A u
ADDCADDCB 2 D wD a A aC v u
SUBSUBB 2 D wD bA u
SUBSUBB 3 D wB bA u
SUBCSUBCB 2 D wD bA a C b1 v u
CMPCMPB 2 D bA u
MULMULU 2 D D a 2 wD

A 2
MULMULU 3 D D a 2 wB

A 2
MULBMULUB 2 D D a 1 wD

A 3
MULBMULUB 3 D D a 1 wB

A 3
DIVU 2 D w(D D a 2)A D a 2 wremainder u 2
DIVUB 2 D w(D D a 1)A D a 1 wremainder u 3
DIV 2 D w(D D a 2)A D a 2 wremainder u 2
DIVB 2 D w(D D a 1)A D a 1 wremainder u 3
ANDANDB 2 D wD and A 0 0
ANDANDB 3 D wB and A 0 0
ORORB 2 D wD or A 0 0
XORXORB 2 D wD (excl or) A 0 0
LDLDB 2 D wA
STSTB 2 A wD
LDBSE 2 D wA D a 1 wSIGN(A) 3 4
LDBZE 2 D wA D a 1 w0 3 4
PUSH 1 SP wSP b2 (SP) wA
POP 1 A w(SP) SP wSP a 2
PUSHF 0 SP wSP b2 (SP) wPSW 0 0 0 0 0 0
PSW w0000H I w0
POPF 0 PSW w(SP) SP wSP a 2 I w
SJMP 1 PC wPC a 11-bit offset 5
LJMP 1 PC wPC a 16-bit offset 5
BR (indirect) 1 PC w(A)
SCALL 1 SP wSP b2 (SP) wPC 5
PC wPC a 11-bit offset
LCALL 1 SP wSP b2 (SP) wPC 5
PC wPC a 16-bit offset
RET 0 PC w(SP) SP wSP a 2
J (conditional) 1 PC wPC a 8-bit offset (if taken) 5
JC 1 Jump if C e 1 5
JNC 1 Jump if C e 0 5
JE 1 Jump if Z e 1 5
Figure 2-5 Instruction Summary
NOTES
1 If the mnemonic ends in B a byte operation is performed otherwise a word operation is done Operands D B and A
must conform to the alignment rules for the required operand type D and B are locations in the register file A can be
located anywhere in memory
2 D D a 2 are consecutive WORDS in memory D is DOUBLE-WORD aligned
3 D D a 1 are consecutive BYTES in memory D is WORD aligned
4 Changes a byte to a word
5 Offset is a 2s complement number
5
AP-248
Mnemonic
Oper-
Operation (Note 1)
Flags
Notes
ands Z N C V VT ST
JNE 1 Jump if Z e 0 5
JGE 1 Jump if N e 0 5
JLT 1 Jump if N e 1 5
JGT 1 Jump if N e 0 and Z e 0 5
JLE 1 Jump if N e 1 or Z e 1 5
JH 1 Jump if C e 1 and Z e 0 5
JNH 1 Jump if C e 0 or Z e 1 5
JV 1 Jump if V e 1 5
JNV 1 Jump if V e 0 5
JVT 1 Jump if VT e 1 Clear VT 0 5
JNVT 1 Jump if VT e 0 Clear VT 0 5
JST 1 Jump if ST e 1 5
JNST 1 Jump if ST e 0 5
JBS 3 Jump if Specified Bit e 1 5 6
JBC 3 Jump if Specified Bit e 0 5 6
DJNZ 1 D wD b1 if D
i
0 then
PC wPC a 8-bit offset 5
DECDECB 1 D wD b1 u
NEGNEGB 1 D w0 bD u
INCINCB 1 D wD a 1 u
EXT 1 D wD D a 2 wSign (D) 0 0 2
EXTB 1 D wD D a 1 wSign (D) 0 0 3
NOTNOTB 1 D wLogical Not (D) 0 0
CLRCLRB 1 D w0 1 0 0 0
SHLSHLBSHLL 2 C wmsb Isb w0 u 7
SHRSHRBSHRL 2 0 xmsb Isb xC 0 7
SHRASHRABSHRAL 2 msb xmsb Isb xC 0 7
SETC 0 C w1 1
CLRC 0 C w0 0
CLRVT 0 VT w0 0
RST 0 PC w2080H 0 0 0 0 0 0 8
DI 0 Disable All Interrupts (I w0)
EI 0 Enable All Interrupts (I w1)
NOP 0 PC wPC a 1
SKIP 0 PC wPC a 2
NORML 2 Left Shift Till msb e 1 D wshift count 0 7
TRAP 0 SP wSP b2 (SP) wPC
PC w(2010H) 9
Figure 2-5 Instruction Summary (Continued)
NOTES
1 If the mnemonic ends in B a byte operation is performed otherwise a word operation is done Operands D B and A
must conform to the alignment rules for the required operand type D and B are locations in the register file A can be
located anywhere in memory
5 Offset is a 2s complement number
6 Specified bit is one of the 2048 bits in the register file
7 The L (Long) suffix indicates double-word operation
8 Initiates a Reset by pulling RESET low Software should re-initialize all the necessary registers with code starting at
2080H
9 The assembler will not accept this mnemonic
6
AP-248
One opeiand of most of the instiuctions can be used
with any one of six addiessing modes. These modes
inciease the fIexibiIity and oveiaII execution speed of
the 8096. The addiessing modes aie: iegistei-diiect, im-
mediate, indiiect, indiiect with auto-inciement, and
Iong and shoit indexed.
The fastest instiuction execution is gained by using ei-
thei iegistei diiect oi immediate addiessing. Registei-
diiect addiessing is simiIai to noimaI diiect addiessing,
except that onIy addiesses in the iegistei fiIe oi SFRs
can be addiessed. The indexed mode is used to diiectIy
addiess the iemaindei of the 64K addiess space. Imme-
diate addiessing opeiates as wouId be expected, using
the data foIIowing the opcode as the opeiand.
Both of the indiiect addiessing modes use the vaIue in a
woid iegistei as the addiess of the opeiand. If the indi-
iect auto-inciement mode is used then the woid iegistei
is inciemented by one aftei a byte access oi by two aftei
a woid access. This mode is paiticuIaiIy usefuI foi ac-
cessing Iookup tabIes.
Access to any of the Iocations in the 64K addiess space
can be obtained by using the Iong indexed addiessing
mode. In this mode a 16-bit 2s compIement vaIue is
added to the contents of a woid iegistei to foim the
addiess of the opeiand. By using the zeio iegistei as the
index, ASM96 (the assembIei) can accept diiect ad-
diessing to any Iocation. The zeio iegistei is Iocated at
0000H and aIways has a vaIue of zeio. A shoit indexed
mode is aIso avaiIabIe to save some time and code. This
mode uses an 8-bit 2s compIement numbei as the offset
instead of a 16-bit numbei.
222 ASSEMBLY LANGUAGE
The muItipIe addiessing modes of the 8096 make it easy
to piogiam in assembIy Ianguage and piovide an exceI-
Ient inteiface to high IeveI Ianguages. The instiuctions
accepted by the assembIei consist of mnemonics foI-
Iowed by eithei addiesses oi data. A Iist of the mne-
monics and theii functions aie shown in Figuie 2-5.
The addiesses oi data aie given in diffeient foimats
depending on the addiessing mode. These modes and
foimats aie shown in Figuie 2-6.
AdditionaI infoimation on 8096 assembIy Ianguage is
avaiIabIe in the MCS-96 Macio AssembIei Useis
Ouide, Iisted in the bibIiogiaphy.
270061B3
Figure 2-6 Instruction Format
7
AP-248
2700614
Figure 2-7 Interrupt Sources
223 INTERRUPTS
The fIexibiIity of the instiuction set is caiiied thiough
into the inteiiupt system. Theie aie 20 diffeient intei-
iupt souices that can be used on the 8096. The 20
souices vectoi thiough 8 Iocations oi inteiiupt vectois.
The vectoi names and theii souices aie shown in Fig-
uie 2-7, with theii Iocations Iisted in Figuie 2-8. Con-
tioI of the inteiiupts is handIed thiough the Inteiiupt
Pending Registei (INT
-
PFNDINO), the Inteiiupt
Mask Registei (INT
-
MASK), and the I bit in the
PSW (PSW.9). Figuie 2-9 shows a bIock diagiam of the
inteiiupt stiuctuie. The INT
-
PFNDINO iegistei
contains bits which get set by haidwaie when an intei-
iupt occuis. If the inteiiupt mask iegistei bit foi that
souice is a 1 and PSW.9
e
1, a vectoi wiII be taken to
the addiess Iisted in the inteiiupt vectoi tabIe foi that
Vector
Source
Location
Priority
(High (Low
Byte) Byte)
Software 2011H 2010H Not Applicable
Extint 200FH 200EH 7 (Highest)
Serial Port 200DH 200CH 6
Software Timers 200BH 200AH 5
HSI0 2009H 2008H 4
High Speed 2007H 2006H 3
Outputs
HSI Data 2005H 2004H 2
Available
AD Conversion 2003H 2002H 1
Complete
Timer Overflow 2001H 2000H 0 (Lowest)
Figure 2-8 Interrupt Vectors and Priorities
8
AP-248
souice. When the vectoi is taken the INT
-
PFNDINO
bit is cIeaied. If moie than one bit is set in the INT
-
PFNDINO iegistei with the coiiesponding bit set in
the INT
-
MASK iegistei, the Inteiiupt with the high-
est piioiity shown in Figuie 2-8 wiII be executed.
The softwaie can make the haidwaie inteiiupts woik in
aImost any fashion desiied by having each ioutine iun
with its own setup in the INT
-
MASK iegistei. This
wiII be cIeaiIy seen in the exampIes in section 4 which
change the piioiity of the vectois in softwaie. The
2700615
Figure 2-9 Interrupt Structure Block Diagram
9
AP-248
15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
Z N V VT C I ST INT

MASK
WHERE
Z is the zero flag It is set when the result of an operation is zero
N is the negative flag It is set to the algebraically correct sign of the result regardless of overflows
V is the overflow flag It is set if an overflow occurs
VT is the overflow trap flag It is set when the VT flag is set and cleared by JVT JNVT or CLRVT
C is the carry flag It is set if a carry was generated by the prior operation
I is the global interrupt enable bit
ST is the sticky bit It is set during a right shift if a one was shifted into and then out of the carry flag
INT

MASK is the interrupt mask register and contains bits which individually enable the 8 interrupt vectors
Figure 2-10 The PSW Register
PSW (shown in Figuie 2-10), stoies the INT
-
MASK
iegistei in its Iowei byte so that the mask iegistei can
be pushed and popped aIong with the machine status
when moving in and out of ioutines. The action of
pushing fIags cIeais the PSW which incIudes PSW.9,
the inteiiupt enabIe bit. Theiefoie, aftei a PUSHF in-
stiuction inteiiupts aie disabIed. In most cases an intei-
iupt seivice ioutine wiII have the basic stiuctuie shown
beIow.
INT VECTOR
PUSHF
LDB INT MASK xxxxxxxxB
EI
-
- Insert service routine here
-
POPF
RET
The PUSHF instiuction saves the PSW incIuding the
oId INT
-
MASK iegistei. The PSW, incIuding the in-
teiiupt enabIe bit aie Ieft cIeaied. If some inteiiupts
need to be enabIed whiIe the seivice ioutine iuns, the
INT
-
MASK is Ioaded with a new vaIue and intei-
iupts aie gIobaIIy enabIed befoie the seivice ioutine
continues. At the end of the seivice ioutine a POPF in-
stiuction is executed to iestoie the oId PSW. The RFT
instiuction is executed and the code ietuins to the de-
siied Iocation. AIthough the POPF instiuction can en-
abIe the inteiiupts the next instiuction wiII aIways exe-
cute. This pievents unnecessaiy buiIding of the stack by
ensuiing that the RFT aIways executes befoie anothei
inteiiupt vectoi is taken.
23 On-Chip IO Section
AII of the on-chip I/O featuies of the 8096 can be ac-
cessed thiough the speciaI function iegisteis, as shown
in Figuie 2-3. The advantage of using iegistei-mapped
I/O is that these iegisteis can be used as the souices oi
destinations of CPU opeiations. Theie aie seven majoi
I/O functions. Fach one of these wiII be consideied
with a section of code to exempIify its usage. The fiist
section coveied wiII be the High Speed I/O, (HSIO),
subsystem. This section incIudes the High Speed Input
(HSI) unit, High Speed Output (HSO) unit, and the
Timei/Countei section.
231 TIMERCOUNTERS
The 8096 has two time bases, Timei 1 and Timei 2.
Timei 1 is a 16-bit fiee iunning timei which is incie-
mented eveiy 8 state times. (A state time is 3 osciIIatoi
peiiods, oi 0.25 micioseconds with a 12 MHz ciystaI.)
10
AP-248
2700616
Pulse measurement with 20 msec resolution
Input transitions trigger the recording of the reference
Timer (16-bit) and triggered input(s) (4-bit)
Figure 2-11 HSI Unit Block Diagram
Its vaIue can be iead at any time and used as a iefei-
ence foi both the HSI section and the HSO section.
Timei 1 can cause an inteiiupt when it oveifIows, and
cannot be modified oi stopped without iesetting the
entiie chip. Timei 2 is ieaIIy an event countei since it
uses an exteinaI cIock souice. Like Timei 1, it is 16-bits
wide, can be iead at any time, can be used with the
HSO section, and can geneiate an inteiiupt when it
oveifIows. ContioI of Timei 2 is Iimited to inciement-
ing it and iesetting it. Specific vaIues can not be wiitten
to it.
AIthough the 8096 has onIy two timeis, the timei fIexi-
biIity is equaI to a unit with many timeis thanks to the
HSIO unit. The HSI enabIes one to measuie times of
exteinaI events on up to foui Iines using Timei 1 as a
timei base. The HSO unit can scheduIe and execute
inteinaI events and up to six exteinaI events based on
the vaIues in eithei Timei 1 oi Timei 2. The 8096 aIso
incIudes sepaiate, dedicated timeis foi the baud iate
geneiatoi and watchdog timei.
232 HSI
The HSI unit can be thought of as a message takei
which iecoids the Iine which had an event and the time
at which the event occuiied. Foui types of events can
tiiggei the HSI unit, as shown in the HSI bIock dia-
giam in Figuie 2-11. The HSI unit can measuie puIse
widths and iecoid times of events with a 2
2700617
Where each 2-bit mode control field
defines one of 4 possible modes
00 8 positive transitions
01 Each positive transition
10 Each negative transition
11 Every transition (positive and negative)
Figure 2-12 HSI Mode Register
11
AP-248
miciosecond iesoIution. It can Iook foi one of foui
events on each of foui Iines simuItaneousIy, based on
the infoimation in the HSI Mode iegistei, shown in
Figuie 2-12. The infoimation is then stoied in a seven
IeveI FIFO foi Iatei ietiievaI. Whenevei the FIFO con-
tains infoimation, the eaiIiest entiy is pIaced in the
hoIding iegistei. When the hoIding iegistei is iead, the
next vaIid piece of infoimation is Ioaded into it. Intei-
iupts can be geneiated by the HSI unit at the time the
hoIding iegistei is Ioaded oi when the FIFO has six oi
moie entiies.
233 HSO
Just as the HSI can be thought of as a message takei,
the HSO can be thought of as a message sendei. At
times deteimined by the softwaie, the HSO sends mes-
2700618
Figure 2-13 HSO Command Register
2700619
Figure 2-14 HSO Block Diagram
12
AP-248
sages to vaiious devices to have them tuin on, tuin off,
stait piocessing, oi ieset. Since the piogiammed times
can be iefeienced to eithei Timei 1 oi Timei 2, the
HSO makes the two timeis Iook Iike many. Foi exam-
pIe, if seveiaI events have to occui at specific times, the
HSO unit can scheduIe aII of the events based on a
singIe timei. The events that can be scheduIed to occui
and the foimat of the command wiitten to the HSO
Command iegistei aie shown in Figuie 2-13.
The softwaie timeis Iisted in the figuie aie actuaIIy 4
softwaie fIags in I/O Status Registei 1 (IOS1). These
fIags can be set, and optionaIIy cause an inteiiupt, at
any time based on Timei 1 oi Timei 2. In most cases
these timeis aie used to tiiggei inteiiupt ioutines which
must occui at ieguIai inteivaIs. A muItitask piocess
can easiIy be set up using the softwaie timeis.
A CAM (Content AddiessabIe Memoiy) fiIe is the
main component of the HSO. This fiIe stoies up to
eight events which aie pending to occui. Fveiy state
time one Iocation of the CAM is compaied with the
two timeis. Aftei 8 state times, (two micioseconds with
a 12 MHz cIock), the entiie CAM has been seaiched
foi time matches. If a match occuis the specified event
wiII be tiiggeied and that Iocation of the CAM wiII be
made avaiIabIe foi anothei pending event. A bIock dia-
giam of the HSO unit is shown in Figuie 2-14.
234 Serial Port
ContioIIing a device fiom a iemote Iocation is a simpIe
task that fiequentIy iequiies additionaI haidwaie with
many piocessois. The 8096 has an on-chip seiiaI poit to
ieduce the totaI numbei of chips iequiied in the system.
27006110
NOTE
TI and RI are cleared when SP

CON is read
Figure 2-15 Serial Port ControlStatus Register
13
AP-248
The seiiaI poit is simiIai to that on the MCS-51 piod-
uct Iine. It has one synchionous and thiee asynchio-
nous modes. In the asynchionous modes baud iates of
up to 187.5 Kbaud can be used, whiIe in the synchio-
nous mode iates up to 1.5 Mbaud aie avaiIabIe. The
chip has a baud iate geneiatoi which is independent of
Timei 1 and Timei 2, so using the seiiaI poit does not
take away any of the HSI, HSO oi timei fIexibiIity oi
functionaIity.
ContioI of the seiiaI poit is piovided thiough the
SPCON/SPSTAT (SeiiaI Poit CONtioI/SeiiaI Poit
STATus) iegistei. This iegistei, shown in Figuie 2-15,
has some bits which aie iead onIy and otheis which aie
wiite onIy. AIthough the functionaIity of the poit is
simiIai to that of the 8051, the names of some of the
modes and contioI bits aie diffeient. The way in which
the poit is used fiom a softwaie standpoint is aIso
sIightIy diffeient since RI and TI aie cIeaied aftei each
iead of the iegistei.
The foui modes of the seiiaI poit aie iefeiied to as
modes 0, 1, 2 and 3. Mode 0 is the synchionous mode,
and is commonIy used to inteiface to shift iegisteis foi
I/O expansion. In this mode the poit outputs a puIse
tiain on the TXD pin and eithei tiansmits oi ieceives
data on the RXD pin. Mode 1 is the standaid asyn-
chionous mode, 8 bits pIus a stop and stait bit aie sent
oi ieceived. Modes 2 and 3 handIe 9 bits pIus a stop and
stait bit. The diffeience between the two is, that in
Mode 2 the seiiaI poit inteiiupt wiII not be activated
unIess the ninth data bit is a one, in Mode 3 the intei-
iupt is activated whenevei a byte is ieceived. These two
modes aie commonIy used foi inteipiocessoi communi-
cation.
Using XTAL1
Mode 0
Baud
Rate
e
XTAL1 frequency
4(Ba1)
B i 0
Others
Baud
Rate
e
XTAL1 frequency
64(Ba1)
Using T2CLK
Mode 0
Baud
Rate
e
T2CLK frequency
B
B i 0
Others
Baud
Rate
e
T2CLK frequency
16B
B i 0
Note that B cannot equal 0 except when using
XTAL1 in other than mode 0
Figure 2-16 Baud Rate Formulas
Baud iates foi aII of the modes aie contioIIed thiough
the Baud Rate iegistei. This is a byte wide iegistei
which is Ioaded sequentiaIIy with two bytes, and intei-
naIIy stoies the vaIue as a woid. The Ieast significant
byte is Ioaded to the iegistei foIIowed by the most sig-
nificant. The most significant bit of the baud vaIue de-
teimines the cIock souice foi the baud iate geneiatoi. If
the bit is a one, the XTAL1 pin is used as the souice, if
it is a zeio, the T2 CLK pin is used. The foimuIas
shown in Figuie 2-16 can be used to caIcuIate the baud
iates. The vaiiabIe B is used to iepiesent the Ieast
significant 15 bits of the vaIue Ioaded into the baud iate
iegistei.
The baud iate iegistei vaIues foi common baud iates
aie shown in Figuie 2-17. These vaIues can be used
when XTAL1 is seIected as the cIock souice foi seiiaI
modes othei than Mode 0. The peicentage deviation
fiom theoieticaI is Iisted to heIp assess the ieIiabiIity of
a given setup. In most cases a seiiaI Iink wiII woik if
theie is Iess than a 2.5% diffeience between the baud
iates of the two systems. This is based on the assump-
tion that 10 bits aie tiansmitted pei fiame and the Iast
bit of the fiame must be vaIid foi at Ieast six-eights of
the bit time. If the two systems deviate fiom theoieticaI
by 1.25% in opposite diiections the maximum toIei-
ance of 2.5% wiII be ieached. Theiefoie, caution must
be used when the baud iate deviation appioaches
1.25% fiom theoieticaI. Note that an XTAL1 fiequen-
cy of 11.0592 MHz can be used with the tabIe vaIues
foi 11 MHz to piovide baud iates that have 0.0 peicent
deviation fiom theoieticaI. In most appIications, how-
evei, the accuiacy avaiIabIe when using an 11 MHz
input fiequency is sufficient.
SeiiaI poit Mode 1 is the easiest mode to use as theie is
IittIe to woiiy about except initiaIization and Ioading
and unIoading SBUF, the SeiiaI poit BUFfei. If paiity
is enabIed, (i.e., PFN
e
1), 7 bits pIus even paiity aie
used instead of 8 data bits. The paiity caIcuIation is
done in haidwaie foi even paiity. Modes 2 and 3 aie
simiIai to Mode 1, except that the ninth bit needs to be
contioIIed and iead. It is aIso not possibIe to enabIe
paiity in Mode 2. When paiity is enabIed in Mode 3 the
ninth bit becomes the paiity bit. If paiity is not enabIed,
(i.e., PFN
e
0), the TB8 bit contioIs the state of the
ninth tiansmitted bit. This bit must be set piioi to each
tiansmission. On ieception, if PFN
e
0, the RB8 bit
indicates the state of the ninth ieceived bit. If paiity is
enabIed, (i.e., PFN
e
1), the same bit is caIIed RPF
(Receive Paiity Fiioi), and is used to indicate a paiity
eiioi.
14
AP-248
XTAL1 Frequency
e
120 MHz
Baud Rate Baud Register Value Percent Error
192K 8009H
a
240
9600 8013H
a
240
4800 8026H
b
016
2400 804DH
b
016
1200 809BH
b
016
300 8270H 000
XTAL1 Frequency
e
110 MHz
192K 8008H
a
054
9600 8011H
a
054
4800 8023H
a
054
2400 8047H
a
054
1200 808EH
b
016
300 823CH
a
001
XTAL1 Frequency
e
100 MHz
192K 8007H
b
170
9600 800FH
b
170
4800 8020H
a
138
2400 8040H
b
016
1200 8081H
b
016
300 8208H
a
003
Figure 2-17 Baud Rate Values for 10 11 12 MHz
The softwaie used to communicate between piocessois
is simpIified by making use of Modes 2 and 3. In a basic
piotocoI the ninth bit is caIIed the addiess bit. If it is set
high then the infoimation in that byte is eithei the ad-
diess of one of the piocessois on the Iink, oi a com-
mand foi aII the piocessois. If the bit is a zeio, the byte
contains infoimation foi the piocessoi oi piocessois
pieviousIy addiessed. In standby mode aII piocessois
wait in Mode 2 foi a byte with the addiess bit set.
When they ieceive that byte, the softwaie deteimines if
the next message is foi them. The piocessoi that is to
ieceive the message switches to Mode 3 and ieceives
the infoimation. Since this infoimation is sent with the
ninth bit set to zeio, none of the piocessois set to Mode
2 wiII be inteiiupted. By using this scheme the oveiaII
CPU time iequiied foi the seiiaI poit is minimized.
A typicaI connection diagiam foi the muIti-piocessoi
mode is shown in Figuie 2-18. This type of communica-
ton can be used to connect peiipheiaIs to a desk top
computei, the axis of a muIti-axis machine, oi any oth-
ei gioup of miciocontioIIeis jointIy peifoiming a task.
15
AP-248
27006111
Figure 2-18 Multiprocessor Communication
Mode 0, the synchionous mode, is typicaIIy used foi
inteifacing to shift iegisteis foi I/O expansion. The
softwaie to contioI this mode invoIves the RFN (Re-
ceivei FNabIe) bit, the cIeaiing of the RI bit, and wiit-
ing to SBUF. To tiansmit to a shift iegistei, RFN is set
to zeio and SBUF is Ioaded with the infoimation. The
infoimation wiII be sent and then the TI fIag wiII be set.
Theie aie two ways to cause a ieception to begin. The
fiist is by causing a iising edge to occui on the RFN
bit, the second is by cIeaiing RI with RFN
e
1. In
eithei case, RI is set again when the ieceived byte is
avaiIabIe in SBUF.
235 A to D CONVERTER
AnaIog inputs aie fiequentIy iequiied in a miciocon-
tioIIei appIication. The 8097 has a 10-bit A to D con-
veitei that can use any one of eight input channeIs. The
conveisions aie done using the successive appioxima-
tion method, and iequiie 168 state times (42 miciosec-
onds with a 12 MHz cIock.)
The iesuIts aie guaianteed monotonic by design of the
conveitei. This means that if the anaIog input voItage
changes, even sIightIy, the digitaI vaIue wiII eithei stay
the same oi change in the same diiection as the anaIog
input. When doing piocess contioI aIgoiithms, it is fie-
quentIy the changes in inputs that aie iequiied, not the
absoIute accuiacy of the vaIue. Foi this ieason, even if
the absoIute accuiacy of a 10-bit conveitei is the same
as that of an 8-bit conveitei, the 10-bit monotonic con-
veitei is much moie usefuI.
Since most of the anaIog inputs which aie monitoied by
a miciocontioIIei change veiy sIowIy ieIative to the 42
miciosecond conveision time, it is acceptabIe to use a
capacitive fiItei on each input instead of a sampIe and
hoId. The 8097 does not have an inteinaI sampIe and
hoId, so it is necessaiy to ensuie that the input signaI
does not change duiing the conveision time. The input
to the A/D must be between ANOND and VRFF.
ANOND must be within a few miIIivoIts of VSS and
VRFF must be within a few tenths of a voIt of VCC.
Using the A to D conveitei on the 8097 can be a veiy
Iow softwaie oveihead task because of the inteiiupt and
HSO unit stiuctuie. The A to D can be staited by the
HSO unit at a pieset time. When the conveision is com-
pIete it is possibIe to geneiate an inteiiupt. By using
these featuies the A to D can be iun undei compIete
inteiiupt contioI. The A to D can aIso be diiectIy
16
AP-248
AD Command Register
27006112
AD Result Register
27006113
Figure 2-19 A to D ResultCommand Register
contioIIed by softwaie fIags which aie Iocated in the
AD
-
RFSULT/AD
-
COMMAND Registei, shown
in Figuie 2-19.
236 PWM REGISTER
AnaIog outputs aie just as impoitant as anaIog inputs
when connecting to a piece of equipment. Tiue digitaI
to anaIog conveiteis aie difficuIt to make on a micio-
piocessoi because of aII of the digitaI noise and the
necessity of pioviding an on chip, ieIativeIy high cui-
ient, iaiI to iaiI diivei. They aIso take up a faii amount
of siIicon aiea which can be bettei used foi othei fea-
tuies. The A to D conveitei does use a D to A, but the
cuiients invoIved aie veiy smaII.
Foi many appIications an anaIog output signaI can be
iepIaced by a PuIse Width ModuIated (PWM) signaI.
This signaI can be easiIy geneiated in haidwaie, and
takes up much Iess siIicon aiea than a tiue D to A. The
signaI is a vaiiabIe duty cycIe, fixed fiequency wave-
foim that can be integiated to piovide an appioxima-
tion to an anaIog output. The fiequency is fixed at a
peiiod of 64 micioseconds foi a 12 MHz cIock speed.
ContioIIing the PWM simpIy iequiies wiiting the de-
siied duty cycIe vaIue (an 8-bit vaIue) to the PWM
Registei. Some typicaI output wavefoims that can be
geneiated aie shown in Figuie 2-20.
Conveiting the PWM signaI to an anaIog signaI vaiies
in difficuIty, depending upon the iequiiements of the
system. Some systems, such as motois oi switching
powei suppIies actuaIIy iequiie a PWM signaI, not a
tiue anaIog one. Foi many othei cases it is necessaiy
onIy to ampIify the signaI so that it switches iaiI-to-iaiI,
and then fiItei it. Switching iaiI-to-iaiI means that the
output of the ampIifiei wiII be a iefeience vaIue when
the input is a IogicaI one, and the output wiII
17
AP-248
be zeio when the input is a IogicaI zeio. The fiItei can
be a simpIe RC netwoik oi an active fiItei. If a Iaige
amount of cuiient is needed a buffei is aIso iequiied.
Foi Iow output cuiients, (Iess than 100 micioamps oi
so), the ciicuit shown in Figuie 2-21 can be used.
The RC netwoik deteimines how quiet the output is,
but the quietei the output, the sIowei it can change.
The design of high accuiacy voItage foIIoweis and ac-
tive fiIteis is beyond the scope of this papei, howevei
many books on the subject aie avaiIabIe.
27006114
Figure 2-20 PWM Output Waveforms
27006115
This resistor limits Rise Time to reduce spikes and high frequency noise
Figure 2-21 PWM to Analog Conversion Circuitry
18

Das könnte Ihnen auch gefallen