EasyManua.ls Logo

Cmsemicon SC8F577 Series - Page 151

Default Icon
181 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
V1.8
SC8F577x
151 / 181
www.mcu.com.cn
19.3 Application for Touch Button Mod
19.3.1 The process of reading “data of touch button” in query mode
1. Enable input of the corresponding IO (including key port and the sensitivity adjustment capacitor
port);
2. Set the TKEN bit in KEYCON2 as 1;
3. Set the touch button control register KEYCON1 (including channel selection, touch button detected
clock configuration, negative voltage of comparator configuration;
4. Set the KEYCON2 (digital filter selection, frequency hopping selection);
5. Set the touch button control register KEYCON1(including touch button clock source selection, etc.);
6. Set the touch button control register KEYCON0 (enable the capacitor and select whether the Internal
shunt capacitor of key port is needed);
7. Set the 0th bit KEN of KEYCON0 from high to low, start the touch button detection;
8. Judge whether the 7th bit KDONE of KEYCON0 is high;
9. Read the 16bits data;
10. Finish touch button detection: KEN=0;
11. Return to step 3 to continue the detection of next channel.
Example: detection of touch button (KEY0) in query mode
KEY_START
LDIA
00H
LD
INTCON, A
; disable interrupt
LDIA
B’00000001’
LD
TRISA, A
; RA0 set as touch button detected port
LDIA
B’01000000’
; RB6 set as sensitivity capacitor port
LD
TRISB, A
SETB
KEYCON2, 0
; enable the touch button mod
LDIA
B’01010000’
LD
KEYCON1, A
; set the negative voltage of comparator, and the
detected clock and channel of touch button
LDIA
02H
LD
KEYCON0, A
; set the digital filtering time
SETB
KEYCON0, 0
; start to detect
WAIT
SNZB
KEYCON0, 7
; wait for detection finish
JP
WAIT
LD
A, KEYDATH
LD
R01, A
; Save the higher 8-bit result to the user-defined ram
LD
A, KEYDATL
LD
R02, A
; Save the lower 8-bit result to the user-defined ram
CLRB
KEYCON0, 0
; end of detection
JP
XXXX
; go to other program

Related product manuals