Implementing a Simple Serial Mouse Controller

AN519
Implementing a Simple Serial Mouse Controller
INTRODUCTION
THEORY OF OPERATION
The mouse is becoming increasingly popular as a
standard pointing data entry device. There is no doubt
that the demand for the mouse is increasing. Various
kinds of mice can be found in the market, including optical mice, opto-mechanical mice, and their close relative, trackballs. The mouse interfaces to the host via a
dedicated interface card or an RS-232 port. Their
mechanisms are very similar. The major electrical
components of a mouse are:
A mouse can be divided into several functional blocks:
•
•
•
•
•
•
•
•
•
A typical functional block diagram is shown in Figure 1.
In Figure 2, three pushbuttons are connected to the
input ports of the PIC16C54. When a switch opening or
closure is detected, a message is formatted and sent to
the host. The X and Y movements are measured by
counting the pulses generated by the photo-couplers.
In the case of an opto-mechanical mouse, the infrared
light emitted by the infrared diode is blocked by the
rotating wheel, so that the pulses are generated on the
photo-transistor side. In case of an optical mouse, the
infrared light emitted by the infrared diode is reflected
off the reflective pad patterned with vertical and
horizontal grid lines. It is then received by the
photo-transistor in the mouse. When any X or Y movement is detected, a message is formatted and sent to
the host.
Microcontroller
Photo-transistors
Infrared emitting diode
Voltage conversion circuit
The intelligence of the mouse is provided by the
microcontroller, therefore the features and performance
of a mouse is greatly related to the microcontroller
used.
This application note describes the implementation of a
serial mouse using the PIC16C54. The PIC16C54 is a
high speed 8-bit CMOS microcontroller offered by
Microchip Technology Inc. It is an ideal candidate for a
mouse controller.
FIGURE 1:
Microcontroller
Button detection
Motion detection
RS-232 signal generation
5V DC power supply unit
FUNCTIONAL BLOCKS OF A SERIAL MOUSE
Quadrature
Encoders
2
RS-232
Port
of
Host
Microcontroller
20
-10V
DC
Power
Conversion
Circuitry
+5V
DC
Pushbuttons
 1997 Microchip Technology Inc.
DS00519C-page 1
AN519
The Microsoft Mouse System and the Mouse Systems device both use serial input techniques. The
Mouse System protocol format contains five bytes of
data. One byte describes the status of three push
buttons, two bytes for the relative X movements and two
bytes for the relative Y movements. The Microsoft protocol format contains three bytes of data describing the
status of two push buttons and the relative X and Y
movements. The details of these protocols are given in
Table 1.
Three lines are connected to the host via the RS-232
port:
• Signal Ground
• Received Data
• Request to Send
FIGURE 2:
“Received Data” carries the message sent by the
mouse. While “Request to Send” provides a –10 VDC
for voltage conversion circuitry. A voltage of +5 VDC is
required for electronic components inside the mouse,
however, +5 VDC is not part of an RS-232 port, so
voltage conversion circuitry is required. This circuit is
typically composed of a 555 timer, Zener diodes, and
capacitors.
An example circuit is shown in Figure 3. Since the current supplied through the RS-232 port is limited to
10 mA, the mouse cannot be designed to consume
more than 10 mA current unless an external power supply is provided. The PIC16C54, running at 4 MHz (1 µs
instruction cycle) can provide a very high tracking
speed. An 8 MHz version of PIC16C54 is also available
if higher performance is desired.
PIC16C54 PIN ASSIGNMENTS
+5 VDC
OSC2
OSC1
RB0
RA0
YCLOCK
RA1
YDATA
RA2
XCLOCK
RA3
XDATA
RB7
Received Data Pin of Host RS-232 Port
Signals From Y-Coord.
Photo-Transistor
RB1
RB2
VDD
MCLR
FIGURE 3:
Signals From X-Coord.
Photo-Transistor
GND
VOLTAGE CONVERSION CIRCUITRY
7
Signal
8
4
RESET
6k
Vcc
Output
GND
Discharge
10k
3
7
-10V to 0V
0V to +10V
555
RS-232 Port
Threshold
Trigger
RTS
6
+5 VDC
Output
2
10 µF
5k
20
33 µF
DS00519C-page 2
0.015 µF
 1997 Microchip Technology Inc.
AN519
ABOUT THE SOFTWARE
ing edge of XCLOCK is detected. For right movement,
XDATA is either LOW at the rising edge of XCLOCK or
HIGH at the falling edge of XCLOCK. The up and down
movement detections follow the same logic. In Table 1,
X7:X0 are data for relative movement. If X is positive, it
implies that the mouse is moving to the right. If X is negative, it implies a movement to the left. Similarly, if Y is
positive, it indicates that the mouse is moving down and
if Y is negative, it indicates that the mouse is moving up.
The pulses generated by the photo-couplers are
checked before every bit is sent. A bit takes 1/1200 second to send, if the distance between the grid lines is 1
mm, the tracking speed will be up to 1200 mm/second.
The major tasks performed by the software are button
scanning, X and Y motion scanning, formatting and
sending serial data to the host. These tasks need to be
performed in parallel in order to gain better tracking
speed. The pulses generated by the photo-couplers are
counted while transmitting the serial signals to the
RS-232 port. The number of pulses reflects the speed
of the movement. The more pulses, the faster the movement.
The directions of movement are determined by the last
states and the present states of the outputs of the
photo-transistors. In Figure 4, XCLOCK and XDATA are
outputs from the photo-transistors corresponding to the
X-axis movement. XDATA is read when a rising or a fall-
FIGURE 4:
VOLTAGE CONVERSION CIRCUITRY
XCLOCK
(XC)
XDATA
(XD)
MOVE RIGHT
MOVE LEFT
MOVE UP
MOVE DOWN
YCLOCK
(YC)
YDATA
(YD)
TABLE 1:
MOUSE SYSTEM AND MICROSOFT PROTOCOLS
Mouse System Format*
Microsoft Format*
Bit
Position
7
6
5
4
3
2
1
0
7
6
5
4
3
2
1
0
Byte 1
1
0
0
0
0
L
M
R
1
1
L
R
Y7
Y6
X7
X6
Byte 2
X7
X6
X5
X4
X3
X2
X1
X0
0
0
X5
X4
X3
X2
X1
X0
Byte 3
Y7
Y6
Y5
Y4
Y3
Y2
Y1
Y0
0
0
Y5
Y4
Y3
Y2
Y1
Y0
Byte 4
X7
X6
X5
X4
X3
X2
X1
X0
Byte 5
Y7
Y6
Y5
Y4
Y3
Y2
Y1
Y0
* L = Left Key Status
M = Middle Key Status
R = Right Key Status
 1997 Microchip Technology Inc.
1 = Pressed
0 = Released
X7-X0 = X-Axis Movement Data
Y7-Y0 = Y-Axis Movement Data
DS00519C-page 3
AN519
The buttons are scanned after a message is sent and
the time used to send the message is used as the
debouncing time. The message is in an RS-232 format
with 1200 baud, eight data bits, no parity, and two stop
bits.
The flowcharts of the main program, subroutine BYTE
and subroutine BIT are shown in Figure 5, Figure 6,
and Figure 7. Figure 5 shows that the trigger flag is set
when any change in button status or X/Y movement is
detected. Subroutine BYTE is called in the main
program five times to send five bytes of information.
Subroutine BYTE controls the status of the “Received
Data” (RD) pin. If Trigger Flag is clear, RD will always
be HIGH. Hence, no message will be sent even when
subroutine BYTE is called. Figure 7 shows that
subroutine BIT counts the number of pulses from the
outputs of the photo-transistors, determines the
directions, and generates a 1/1200 second delay to get
1200 baud timing.
The mouse has been tested in Mouse System Mode
and functions properly. The setup and software have
been tested and function within the given guidlines. A
listing of the source program is given in Appendix A.
FIGURE 5:
FLOWCHART OF THE MAIN
PROGRAM
Reset Entry
Initialize I/O port - Get initial button status
Button
status
change?
No
Yes
Set trigger flag
X
movement
count = 0?
Yes
No
Set trigger flag
SUMMARY
The PIC16C54 from Microchip Technology Inc.
provides a very cost-effective, high performance mouse
implementation. Its
low
power
consumption
(typically< 2 mA at 1 µs instruction cycle), small package (18-pin) and high reliability (on-chip watchdog
timer to prevent software hang-ups) are some of the
many reasons why the PIC16C54 is uniquely suitable
for mouse applications.
Note:
This application note provides the user
with a simple, fully functional serial mouse
implementation. The user may use this as
a starting point for a more comprehensive
design.
Right
flag
set?
Yes
Negate X count
No
Y
movement
count = 0?
Yes
No
Set trigger flag
Up
flag
set?
Yes
Negate Y count
No
Data ← Button Byte
Call Routine BYTE
Data ← X-Coord Byte
Call Routine BYTE
Data ← Y-Coord Byte
Call Routine BYTE
Data ← X-Coord Byte
Call Routine BYTE
Data ← Y-Coor. Byte
Call Routine BYTE
Set trigger flag
DS00519C-page 4
 1997 Microchip Technology Inc.
AN519
FIGURE 6:
FLOWCHART OF ROUTINE BYTE
BYTE
Count → '0'
TRIGGER
flag
set?
Yes
'0' → RD pin
(Start Bit)
No
Call routine BIT
TRIGGER
flag
set?
No
Yes
Shift LSb of data
to Carry
0
Carry = 0/1?
'0' → RD Pin
1
'1' → RD pin
Call Routine BIT
Count ← Count +
No
Count = 8?
Yes
Return to Caller
 1997 Microchip Technology Inc.
DS00519C-page 5
AN519
FIGURE 7:
FLOWCHART OF ROUTINE BIT
BIT
0
XC
XC = 0/1?
1
No
No
?
XC
?
Yes
Yes
X Count ← X Count + 1
Reset RIGHT Flag
XD = 0/1?
X Count ← X Count + 1
Reset RIGHT Flag
1
0
XD = 0/1?
0
1
Set RIGHT Flag
Set RIGHT Flag
0
YC
YC = 0/1?
No
1
No
?
YC
?
Yes
Yes
Y Count ← Y Count + 1
Reset UP Flag
YD = 0/1?
Y Count ← Y Count + 1
Reset UP Flag
0
1
0
YD = 0/1?
1
Set UP flag
Set TRIGGER flag
Delay 0.833 ms
Return to Caller
DS00519C-page 6
 1997 Microchip Technology Inc.
AN519
Please check the Microchip BBS for the latest version of the source code. Microchip’s Worldwide Web Address:
www.microchip.com; Bulletin Board Support: MCHIPBBS using CompuServe® (CompuServe membership not
required).
APPENDIX A: MOUSE.ASM
MPASM 01.40 Released
LOC OBJECT CODE
VALUE
00000003
00000005
00000006
00000008
0000000C
0000000D
0000000E
0000000F
00000010
00000011
00000012
00000013
00000014
00000015
00000016
00000018
00000019
00000000
00000001
00000001
00000002
00000003
00000003
00000000
00000002
00000000
00000007
00000002
00000002
MOUSE.ASM
1-16-1997
12:44:22
PAGE
1
LINE SOURCE TEXT
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
 1997 Microchip Technology Inc.
TITLE “ MOUSE “
LIST
P=16C54,R=O
;
;
;********************************************************************
;
;
MOUSE CONTROLLER
;
PIC MODE = PIC16C54XT
CLK=4.0MHZ
;
;
Program:
MOUSE.ASM
;
Revision Date:
25 APRIL, 1990
;
1-13-97
Compatibility with MPASMWIN 1.40
;
;********************************************************************
;
;------------------------------------------;
FILES ASSIGNMENT
;------------------------------------------;
STATUS
EQU 3
;STATUS REGISTER
RA
EQU 5
;I/O PORT A
RB
EQU 6
;I/O PORT B
TIMER1
EQU 10
;COUNTER FOR DELAY
CSTAT
EQU 14
;CO-ORDINATE STATUS
BSTAT
EQU 15
;BUTTON STATUS
DATA0
EQU 16
;
DATA1
EQU 17
;
DATA2
EQU 20
;5 BYTE RS232 DATA
DATA3
EQU 21
;
DATA4
EQU 22
;
FLAGA
EQU 23
;GENERAL PURPOSE FLAG
XCOUNT
EQU 24
;X-MOVEMENT COUNTER
YCOUNT
EQU 25
;Y-MOVEMENT COUNTER
FLAGB
EQU 26
;GENERAL PURPOSE FLAG
COUNT
EQU 30
;GENERAL PURPOSE COUNTER
DATA_AREA EQU 31
;FOR TEMP. STORAGE
;
;-----------------------------------------;
BIT ASSIGNMENT
;-----------------------------------------;
YC
EQU 0
;Y-CLOCK PIN
YD
EQU 1
;Y-DATA PIN
UP
EQU 1
;MOVING UP FLAG
XC
EQU 2
;X-CLOCK PIN
XD
EQU 3
;X-DATA PIN
RI
EQU 3
;MOVING RIGHT FLAG
BU1
EQU 0
;BUTTON #1 PIN
BU2
EQU 2
;BUTTON #2 PIN
CA
EQU 0
;CARRY FLAG
RD
EQU 7
;RECEIVED DATA PIN TO RS232
ZERO_AREA EQU 2
;ZERO FLAG
TR
EQU 2
;TIGGER FLAG
;
DS00519C-page 7
AN519
00000001
0000
0000
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
000A
000A
000B
000C
000D
000E
000F
0010
0011
0011
0012
0013
0014
0015
0016
0017
0018
0019
001A
001B
001B
001C
001D
001E
001F
0020
0021
0022
0022
0023
0024
0025
0026
0026
0027
0028
0029
0745
0A0A
064C
0A11
02B4
0476
0765
0A11
0576
0A11
074C
0A11
02B4
0476
0665
0A11
0576
0705
0A1B
060C
0A22
02B5
0436
0725
0A22
0536
0A22
070C
0A22
02B5
0436
0625
0A22
0536
0205
002C
0CC1
0028
0000
02E8
0A26
0800
DS00519C-page 8
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
F
EQU 1
;
;===========================================
;
SUBROUTINES
;===========================================
;
;*******************************************
ORG 0
;*******************************************
;
;===========================================
; DELAY A BIT TIME AND CHECK XC & YC STATUS
;===========================================
BIT
BTFSS
RA,XC
;XC = 1 ?
GOTO
BIT0
BTFSC
CSTAT,XC
;(XC=1)
GOTO
BITY
;(XC ALWAYS = 1)
INCF
XCOUNT, F
;(XC --|__)
BCF
FLAGB,RI
;DEFAULT LEFT
BTFSS
RA,XD
;LEFT / RIGHT ?
GOTO
BITY
BSF
FLAGB,RI
GOTO
BITY
BIT0
BTFSS
CSTAT,XC
;(XC=0)
GOTO
BITY
;(XC ALWAYS = 0)
INCF
XCOUNT, F
;(XC __|--)
BCF
FLAGB,RI
;DEFAULT LEFT
BTFSC
RA,XD
;LEFT / RIGHT ?
GOTO
BITY
BSF
FLAGB,RI
BITY
BTFSS
RA,YC
;YC = 1 ?
GOTO
BITY0
BTFSC
CSTAT,YC
;(YC=1)
GOTO
BITDY
;(YC ALWAYS = 1)
INCF
YCOUNT, F
;(YC --|__)
BCF
FLAGB,UP
;DEFAULT DOWN
BTFSS
RA,YD
;DOWN / UP ?
GOTO
BITDY
BSF
FLAGB,UP
GOTO
BITDY
BITY0
BTFSS
CSTAT,YC
;(YC=0)
GOTO
BITDY
;(YC ALWAYS = 0)
INCF
YCOUNT, F
;(YC __|--)
BCF
FLAGB,UP
;DEFAULT DOWN
BTFSC
RA,YD
;DOWN / UP ?
GOTO
BITDY
BSF
FLAGB,UP
BITDY
MOVF
RA,W
;SAVE COOR. STATUS
MOVWF
CSTAT
MOVLW
193D
;0.833 MS DELAY
MOVWF
TIMER1
BITD0
NOP
DECFSZ TIMER1, F
GOTO
BITD0
RETLW 0
;
;=================================================
;
;************************************************
;*
SUBROUTINE TO SEND A BYTE
*
 1997 Microchip Technology Inc.
AN519
002A
002A
002B
002C
002D
002E
002E
002F
002F
0030
0031
0032
0033
0034
0035
0036
0036
0037
0037
0038
0039
003A
003B
003C
003D
003E
003F
0040
0041
0042
0042
0043
0044
0044
0045
0045
0046
0047
0048
0049
004A
004B
004C
004D
004E
004F
0050
0051
0052
0053
0054
0055
0056
0056
0057
0058
0059
005A
0078
0753
0A2E
04E6
0900
0753
0A37
0339
0703
0A36
05E6
0A37
04E6
0900
02B8
0778
0A2F
0753
0A42
04E6
0900
05E6
0900
0A44
0900
0900
0800
0CC1
0002
0C0F
0006
0CFF
0005
05E6
0246
0E05
0D80
002D
002E
0205
002C
0073
0074
0075
006F
0070
0071
0072
0214
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
 1997 Microchip Technology Inc.
;*
AS RS232C FORMAT 8,N,1
*
;************************************************
;
BYTE
CLRF
COUNT
;RESET 8 BIT COUNT
BTFSS
FLAGA,TR
;ANY TRIGGER
GOTO
BYTE0
BCF
RB,RD
;LOW RD FOR START BIT
BYTE0
CALL
BIT
BYTE1
BTFSS
FLAGA,TR
;ANY TRIGGER ?
GOTO BYTE3
RRF
DATA_AREA, F
;SHIFT DATA TO CARRY
BTFSS
STATUS,CA
;0 / 1 ?
GOTO
BYTE2
BSF
RB,RD
;SEND A 1
GOTO
BYTE3
BYTE2
BCF
RB,RD
;SEND A 0
BYTE3
CALL
BIT
INCF
COUNT, F
BTFSS
COUNT,3
;COUNT = 8 ?
GOTO
BYTE1
BTFSS
FLAGA,TR
;ANY TRIGGER ?
GOTO
BYTE4
BCF
RB,RD
;SEND SENT BIT
CALL
BIT
BSF
RB,RD
CALL
BIT
GOTO
BYTE5
BYTE4
CALL
BIT
CALL
BIT
BYTE5
RETLW
0
;
;============================================
;
RESET ENTRY
;============================================
;
INIT
MOVLW
B’11000001’
;DISABLE WATCHDOG
OPTION
MOVLW
B’00001111’
;INIT RB0~3 BE INPUTS
TRIS
RB
;RB4~7 BE OUTPUTS
MOVLW
B’11111111’
;INIT RA0~3 BE INPUTS
TRIS
RA
BSF
RB,RD
;HIGH RD PIN
COMF
RB,W
;GET INIT BUTTON INPUTS
ANDLW
B’00000101’
IORLW
B’10000000’
MOVWF
BSTAT
MOVWF
DATA0
MOVF
RA,W
MOVWF
CSTAT
CLRF
FLAGA
;CLEAR TR FLAG
CLRF
XCOUNT
;RESET XCOUNT & YCOUNT
CLRF
YCOUNT
SCAN
CLRF
DATA1
;UPDATE X,Y MOVEMENT DATA
CLRF
DATA2
CLRF
DATA3
CLRF
DATA4
MOVF
XCOUNT,W
;XCOUNT = 0 ?
DS00519C-page 9
AN519
005B
005C
005D
005D
005E
005F
0060
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
006A
006B
006B
006C
006D
006E
006F
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
007A
007B
007C
007D
007E
007F
0080
0080
0081
0082
0083
0084
0085
0085
0086
0087
0088
0089
0089
008A
008B
008C
0743
0A80
0215
0743
0A92
0246
0E05
0D80
00AD
0643
0A6B
0553
0246
0E05
0D80
002E
0246
0E05
0D80
002D
020E
0039
092A
020F
0039
092A
0210
0039
092A
0211
0039
092A
0212
0039
092A
0453
0A56
0553
0C40
0094
0603
0A8D
0776
0A90
0274
0294
002F
0031
0074
0A5D
008D
008D 0C40
008E 0034
008F 0A85
0090
0090 0214
0091 0A89
DS00519C-page 10
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
BTFSS
GOTO
SCANA
MOVF
BTFSS
GOTO
SCANB
COMF
ANDLW
IORLW
SUBWF
BTFSC
GOTO
BSF
COMF
ANDLW
IORLW
MOVWF
SCANC
COMF
ANDLW
IORLW
MOVWF
MOVF
MOVWF
CALL
MOVF
MOVWF
CALL
MOVF
MOVWF
CALL
MOVF
MOVWF
CALL
MOVF
MOVWF
CALL
BCF
GOTO
;
WRITX
BSF
MOVLW
SUBWF
BTFSC
GOTO
WRITS
BTFSS
GOTO
COMF
INCF
WRITA
MOVWF
MOVWF
CLRF
GOTO
;
WRITR
MOVLW
MOVWF
GOTO
;
WRITL
MOVF
GOTO
STATUS,ZERO_AREA
WRITX
YCOUNT,W
STATUS,ZERO_AREA
WRITY
;YCOUNT = 0 ?
RB,W
B’00000101’
B’10000000’
BSTAT, F
STATUS,ZERO_AREA
SCANC
FLAGA,TR
RB,W
B’00000101’
B’10000000’
DATA0
;BUTTON STATUS CHANGE ?
RB,W
B’00000101’
B’10000000’
BSTAT
DATA0,W
DATA_AREA
BYTE
DATA1,W
DATA_AREA
BYTE
DATA2,W
DATA_AREA
BYTE
DATA3,W
DATA_AREA
BYTE
DATA4,W
DATA_AREA
BYTE
FLAGA,TR
SCAN
FLAGA,TR
40H
XCOUNT,W
STATUS,CA
WRITR
FLAGB,RI
WRITL
XCOUNT, F
XCOUNT,W
DATA1
DATA3
XCOUNT
SCANA
;IF CHANGE THEN TRIGGER
;(NO CHANGE)
;(CHANGE) SET TRIGGER FLAG
;FORMAT BUTTON STATUS DATA
;SEND DATA0,1,2,3,4 TO HOST
;CLEAR TRIGGER FLAG
;SET TRIGGER FLAG
;IF XCOUNT > 64 THEN XCOUNT <-64
;LEFT / RIGHT ?
;(RIGHT) NEG XCOUNT
;RESET XCOUNT
40H
XCOUNT
WRITS
;XCOUNT <- 64
XCOUNT,W
WRITA
;(LEFT)
 1997 Microchip Technology Inc.
AN519
0092
0092
0093
0094
0095
0096
0097
0097
0098
0099
009A
009B
009B
009C
009D
009E
0553
0C40
0095
0603
0A9F
0736
0AA2
0275
0295
0030
0032
0075
0A60
009F
009F 0C40
00A0 0035
00A1 0A97
00A2
00A2 0215
00A3 0A9B
01FF
01FF 0A45
0000
0040
0080
01C0
:
:
:
:
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
----------------
;
WRITY
BSF
FLAGA,TR
;SET TRIGGER FLAG
MOVLW 40H
;IF YCOUNT > 64 THEN YCOUNT <-64
SUBWF YCOUNT,W
BTFSC STATUS,CA
GOTO
WRITV
WRITW
BTFSS FLAGB,UP
;DOWN / UP ?
GOTO
WRITD
COMF
YCOUNT, F
;(UP) NEG YCOUNT
INCF
YCOUNT,W
WRITB
MOVWF DATA2
MOVWF DATA4
CLRF
YCOUNT
;RESET YCOUNT
GOTO
SCANB
;
WRITV
MOVLW 40H
;YCOUNT <- 64
MOVWF YCOUNT
GOTO
WRITW
;
WRITD
MOVF
YCOUNT,W
;(DOWN)
GOTO
WRITB
;
;===========================================
;
RESET ENTRY
;===========================================
;
ORG
777
GOTO
INIT
;JUMP TO PROGRAM STARTING
;
END
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
----------------
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
XXXX---------------------------
XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
------------------------------X
All other memory blocks unused.
Program Memory Words Used:
Program Memory Words Free:
Errors
:
Warnings :
Messages :
0
0 reported,
0 reported,
 1997 Microchip Technology Inc.
165
347
0 suppressed
0 suppressed
DS00519C-page 11
Note the following details of the code protection feature on PICmicro® MCUs.
•
•
•
•
•
•
The PICmicro family meets the specifications contained in the Microchip Data Sheet.
Microchip believes that its family of PICmicro microcontrollers is one of the most secure products of its kind on the market today,
when used in the intended manner and under normal conditions.
There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our knowledge, require using the PICmicro microcontroller in a manner outside the operating specifications contained in the data sheet.
The person doing so may be engaged in theft of intellectual property.
Microchip is willing to work with the customer who is concerned about the integrity of their code.
Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as “unbreakable”.
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of
our product.
If you have any further questions about this matter, please contact the local sales office nearest to you.
Information contained in this publication regarding device
applications and the like is intended through suggestion only
and may be superseded by updates. It is your responsibility to
ensure that your application meets with your specifications.
No representation or warranty is given and no liability is
assumed by Microchip Technology Incorporated with respect
to the accuracy or use of such information, or infringement of
patents or other intellectual property rights arising from such
use or otherwise. Use of Microchip’s products as critical components in life support systems is not authorized except with
express written approval by Microchip. No licenses are conveyed, implicitly or otherwise, under any intellectual property
rights.
Trademarks
The Microchip name and logo, the Microchip logo, FilterLab,
KEELOQ, microID, MPLAB, PIC, PICmicro, PICMASTER,
PICSTART, PRO MATE, SEEVAL and The Embedded Control
Solutions Company are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.
dsPIC, ECONOMONITOR, FanSense, FlexROM, fuzzyLAB,
In-Circuit Serial Programming, ICSP, ICEPIC, microPort,
Migratable Memory, MPASM, MPLIB, MPLINK, MPSIM,
MXDEV, PICC, PICDEM, PICDEM.net, rfPIC, Select Mode
and Total Endurance are trademarks of Microchip Technology
Incorporated in the U.S.A.
Serialized Quick Turn Programming (SQTP) is a service mark
of Microchip Technology Incorporated in the U.S.A.
All other trademarks mentioned herein are property of their
respective companies.
© 2002, Microchip Technology Incorporated, Printed in the
U.S.A., All Rights Reserved.
Printed on recycled paper.
Microchip received QS-9000 quality system
certification for its worldwide headquarters,
design and wafer fabrication facilities in
Chandler and Tempe, Arizona in July 1999. The
Company’s quality system processes and
procedures are QS-9000 compliant for its
PICmicro® 8-bit MCUs, KEELOQ® code hopping
devices, Serial EEPROMs and microperipheral
products. In addition, Microchip’s quality
system for the design and manufacture of
development systems is ISO 9001 certified.
 2002 Microchip Technology Inc.
M
WORLDWIDE SALES AND SERVICE
AMERICAS
ASIA/PACIFIC
Japan
Corporate Office
Australia
2355 West Chandler Blvd.
Chandler, AZ 85224-6199
Tel: 480-792-7200 Fax: 480-792-7277
Technical Support: 480-792-7627
Web Address: http://www.microchip.com
Microchip Technology Australia Pty Ltd
Suite 22, 41 Rawson Street
Epping 2121, NSW
Australia
Tel: 61-2-9868-6733 Fax: 61-2-9868-6755
Microchip Technology Japan K.K.
Benex S-1 6F
3-18-20, Shinyokohama
Kohoku-Ku, Yokohama-shi
Kanagawa, 222-0033, Japan
Tel: 81-45-471- 6166 Fax: 81-45-471-6122
Rocky Mountain
China - Beijing
2355 West Chandler Blvd.
Chandler, AZ 85224-6199
Tel: 480-792-7966 Fax: 480-792-7456
Microchip Technology Consulting (Shanghai)
Co., Ltd., Beijing Liaison Office
Unit 915
Bei Hai Wan Tai Bldg.
No. 6 Chaoyangmen Beidajie
Beijing, 100027, No. China
Tel: 86-10-85282100 Fax: 86-10-85282104
Atlanta
500 Sugar Mill Road, Suite 200B
Atlanta, GA 30350
Tel: 770-640-0034 Fax: 770-640-0307
Boston
2 Lan Drive, Suite 120
Westford, MA 01886
Tel: 978-692-3848 Fax: 978-692-3821
Chicago
333 Pierce Road, Suite 180
Itasca, IL 60143
Tel: 630-285-0071 Fax: 630-285-0075
Dallas
4570 Westgrove Drive, Suite 160
Addison, TX 75001
Tel: 972-818-7423 Fax: 972-818-2924
Detroit
Tri-Atria Office Building
32255 Northwestern Highway, Suite 190
Farmington Hills, MI 48334
Tel: 248-538-2250 Fax: 248-538-2260
Kokomo
2767 S. Albright Road
Kokomo, Indiana 46902
Tel: 765-864-8360 Fax: 765-864-8387
Los Angeles
18201 Von Karman, Suite 1090
Irvine, CA 92612
Tel: 949-263-1888 Fax: 949-263-1338
China - Chengdu
Microchip Technology Consulting (Shanghai)
Co., Ltd., Chengdu Liaison Office
Rm. 2401, 24th Floor,
Ming Xing Financial Tower
No. 88 TIDU Street
Chengdu 610016, China
Tel: 86-28-6766200 Fax: 86-28-6766599
China - Fuzhou
Microchip Technology Consulting (Shanghai)
Co., Ltd., Fuzhou Liaison Office
Unit 28F, World Trade Plaza
No. 71 Wusi Road
Fuzhou 350001, China
Tel: 86-591-7503506 Fax: 86-591-7503521
China - Shanghai
Microchip Technology Consulting (Shanghai)
Co., Ltd.
Room 701, Bldg. B
Far East International Plaza
No. 317 Xian Xia Road
Shanghai, 200051
Tel: 86-21-6275-5700 Fax: 86-21-6275-5060
China - Shenzhen
150 Motor Parkway, Suite 202
Hauppauge, NY 11788
Tel: 631-273-5305 Fax: 631-273-5335
Microchip Technology Consulting (Shanghai)
Co., Ltd., Shenzhen Liaison Office
Rm. 1315, 13/F, Shenzhen Kerry Centre,
Renminnan Lu
Shenzhen 518001, China
Tel: 86-755-2350361 Fax: 86-755-2366086
San Jose
Hong Kong
Microchip Technology Inc.
2107 North First Street, Suite 590
San Jose, CA 95131
Tel: 408-436-7950 Fax: 408-436-7955
Microchip Technology Hongkong Ltd.
Unit 901-6, Tower 2, Metroplaza
223 Hing Fong Road
Kwai Fong, N.T., Hong Kong
Tel: 852-2401-1200 Fax: 852-2401-3431
New York
Toronto
6285 Northam Drive, Suite 108
Mississauga, Ontario L4V 1X5, Canada
Tel: 905-673-0699 Fax: 905-673-6509
India
Microchip Technology Inc.
India Liaison Office
Divyasree Chambers
1 Floor, Wing A (A3/A4)
No. 11, O’Shaugnessey Road
Bangalore, 560 025, India
Tel: 91-80-2290061 Fax: 91-80-2290062
Korea
Microchip Technology Korea
168-1, Youngbo Bldg. 3 Floor
Samsung-Dong, Kangnam-Ku
Seoul, Korea 135-882
Tel: 82-2-554-7200 Fax: 82-2-558-5934
Singapore
Microchip Technology Singapore Pte Ltd.
200 Middle Road
#07-02 Prime Centre
Singapore, 188980
Tel: 65-6334-8870 Fax: 65-6334-8850
Taiwan
Microchip Technology Taiwan
11F-3, No. 207
Tung Hua North Road
Taipei, 105, Taiwan
Tel: 886-2-2717-7175 Fax: 886-2-2545-0139
EUROPE
Denmark
Microchip Technology Nordic ApS
Regus Business Centre
Lautrup hoj 1-3
Ballerup DK-2750 Denmark
Tel: 45 4420 9895 Fax: 45 4420 9910
France
Microchip Technology SARL
Parc d’Activite du Moulin de Massy
43 Rue du Saule Trapu
Batiment A - ler Etage
91300 Massy, France
Tel: 33-1-69-53-63-20 Fax: 33-1-69-30-90-79
Germany
Microchip Technology GmbH
Gustav-Heinemann Ring 125
D-81739 Munich, Germany
Tel: 49-89-627-144 0 Fax: 49-89-627-144-44
Italy
Microchip Technology SRL
Centro Direzionale Colleoni
Palazzo Taurus 1 V. Le Colleoni 1
20041 Agrate Brianza
Milan, Italy
Tel: 39-039-65791-1 Fax: 39-039-6899883
United Kingdom
Arizona Microchip Technology Ltd.
505 Eskdale Road
Winnersh Triangle
Wokingham
Berkshire, England RG41 5TU
Tel: 44 118 921 5869 Fax: 44-118 921-5820
03/01/02
 2002 Microchip Technology Inc.