
232
EPSON
S1C88409 TECHNICAL MANUAL
APPENDIX: CONTROLLING THE TOUCH PANEL CONTROLLER
A.5 Reference Program
A.5.1 Setting constants and macros (include file)
;*******************************************************************************
;
SYS_CONST.INC
system constant data
;
--------------------------------------------
;
Copyright(C) 1997 Seiko Epson Co.,Ltd
;*******************************************************************************
(1) Set flags
;=============
tpc_flg0
======================================================
TCDT_RCV
EQU
00000001B
;1: coordinate calculation is finished
TC_SWITCH0
EQU
00000010B
;switch detected in pen-move interrupt
TC_SWITCH1
EQU
00000100B
;switch translated in coordinate calc.loutine
WAITTIMER
EQU
00001000B
;wait timer for pen down setting
(2) Define Macros
;-------------
macro declaration
-------------------------
;<bit set macro>
M_BSET
MACRO
DATA,DBIT,REG
LD
REG,[DATA]
OR
REG,#DBIT
LD
[DATA],REG
ENDM
;<bit clear macro>
M_BCLR
MACRO
DATA,DBIT,REG
LD
REG,#DBIT
XOR
REG,#0FFH
AND
REG,[DATA]
LD
[DATA],REG
ENDM
;<I/O register bit clear macro>
M_IO_BCLR
MACRO
DATA,DBIT
AND
[BR:@LOW(DATA)],#DBIT0FFH
ENDM
;<I/O register bit set macro>
M_IO_BSET
MACRO
DATA,DBIT
OR
[BR:@LOW(DATA)],#DBIT
ENDM
A.5.2 TPC initialization
;###############################################################################
;
touch panel controller initialize
;
input
none
;
output
none
;
destroyed
none
;###############################################################################
GLOBAL
TOUCH_INI
TOUCH_INI:
;ETPPD,ETPDR,PDC,RST is initial 0
;TP interrupt priority PTP* is set in other previous routine
(1) Save the register values into the stack
PUSH
SC
PUSH
A
(2) Switch to the high-speed clock
CARL
CLK_LtoH
;change the clock to high
(3) Supply clocks to the A/D converter and TPC
LD
[BR:@LOW(IO_PRE3)],#00001010B
;A/D clock = fOSC3/4
;A/D clock is turned on