Вы находитесь на странице: 1из 27

NuMicro Nano100

Touch Key

NuMicro@nuvoton.com

2013/02/27
Agenda
• Feature
• TK Block diagram
• Key Scan
• TK Related Register and Memory Map
• TK Sensitivity Adjustment
• TK Sample Code & Tool Introduction
• Tool Implementation (Nu-LB-Nano130 or NuTouch)

1
Feature
• Support up to 16 touch key scanning
• Programmable counter depth(16, 14, 12, 10-bit)
• Sensitivity adjustment
• Programmable charge current
• Programmable clock source frequency
• Programmable clock divider for each channel
• Support periodic (Timer0) or software key scan
• Scan up to 8 channels per scan cycle

2
Block Diagram

3
Key Scan

Data Data
Overflow Overflow

Difference

Base

Time Time
Finger off Finger on

Timer
RC counter

4
Start Touch Key Scanning
• Scan up to 8 channels each time
• Channel (0, 8) (1, 9) … (7, 15) are mutual exclusive
• Software can write START_SCAN_BY_MANU 1 to start
scan if START_SCAN_BY_TIMER_EN is 0
• Timer 0 can trigger scan if
START_SCAN_BY_TIMER_EN is 1
• Timer 0 can trigger TK even system is in power down mode
• Start event can be dropped if TK is still scanning

5
Interrupt
• Scan complete interrupt
• Scan failed interrupt
• Threshold interrupt
• Sense result less than low threshold
• Sense result larger than high threshold

6
Register and Memory Map
Register Offset R/W Description Reset Value
TK Base Address:
TK_BA = 0x400C_0000
TK_CTL1 TK_BA+0x00 R/W Touch Key Control Register 1 0x0000_0000
TK_CTL2 TK_BA+0x04 R/W Touch Key Control Register 2 0x4040_4040
TK_CTL3 TK_BA+0x08 R/W Touch Key Control Register 3 0x4040_4040
TK_STAT TK_BA+0x0C R Touch Key Status Register 0x0000_0000
TK_DATA1 TK_BA+0x10 R Touch Key Data Register 1 0x0000_0000
TK_DATA2 TK_BA+0x14 R Touch Key Data Register 2 0x0000_0000
TK_DATA3 TK_BA+0x18 R Touch Key Data Register 3 0x0000_0000
TK_DATA4 TK_BA+0x1C R Touch Key Data Register 4 0x0000_0000
TK_INTEN TK_BA+0x20 R/W Touch Key Interrupt Enable Register 0x0000_0000
TK8_0_THC TK_BA+0x24 R/W TK8/TK0 Threshold Control Register 0x0000_0000
TK9_1_THC TK_BA+0x28 R/W TK9/TK1 Threshold Control Register 0x0000_0000
TK10_2_THC TK_BA+0x2C R/W TK10/TK2 Threshold Control Register 0x0000_0000
TK11_3_THC TK_BA+0x30 R/W TK11/TK3 Threshold Control Register 0x0000_0000
TK12_4_THC TK_BA+0x34 R/W TK12/TK4 Threshold Control Register 0x0000_0000
TK13_5_THC TK_BA+0x38 R/W TK13/TK5 Threshold Control Register 0x0000_0000
TK14_6_THC TK_BA+0x3C R/W TK14/TK6 Threshold Control Register 0x0000_0000
TK15_7_THC TK_BA+0x40 R/W TK15/TK7 Threshold Control Register 0x0000_0000

7
Register – (1)
Register Offset R/W Description Reset Value

TK_CTL1 TK_BA+0x00 R/W Touch Key Control Register 1 0x0000_0000

31 30 29 28 27 26 25 24

TK_EN TK_SEN_SEL Reserved Reserved

23 22 21 20 19 18 17 16

START_
Adjust START_
SCAN
Depth (Data Valid bits)
Reserved SCAN_BY_M
_BY_
ANU
TIMER_EN

15 14 13 12 11 10 9 8

EN_TK15_7 EN_TK14_6 EN_TK13_5 EN_TK12_4 EN_TK11_3 EN_TK10_2 EN_TK9_1 EN_TK8_0

7 6 5 4 3 2 1 0

SEL_TK15_7 SEL_TK14_6 SEL_TK13_5 SEL_TK12_4 SEL_TK11_3 SEL_TK10_2 SEL_TK9_1 SEL_TK8_0

8
Register – (2)
Register Offset R/W Description Reset Value

TK_CTL2 TK_BA+0x04 R/W Touch Key Control Register 2 0x4040_4040

31 30 29 28 27 26 25 24

TK11_3_CUR_CTRL TK11_3_TBCLK_DIV

23 22 21 20 19 18 17 16

TK10_2_CUR_CTRL TK10_2_TBCLK_DIV

15 14 13 12 11 10 9 8

TK9_1_CUR_CTRL TK9_1_TBCLK_DIV

7 6 5 4 3 2 1 0

TK8_0_CUR_CTRL TK8_0_TBCLK_DIV

Adjust Adjust
Charge / Discharge Current Time Base Clock Frequency

9
Register – (3)
Register Offset R/W Description Reset Value

TK_STAT TK_BA+0x0C R Touch Key Status Register 0x0000_0000

31 30 29 28 27 26 25 24

Reserved

23 22 21 20 19 18 17 16

TK15_7_THC TK14_6_THC TK13_5_THC TK12_4_THC TK11_3_THC TK10_2_THC TK9_1_THC_ TK8_0_THC_


_ST _ST _ST _ST _ST _ST ST ST

15 14 13 12 11 10 9 8

TK15_7_SEN TK14_6_SEN TK13_5_SEN TK12_4_SEN TK11_3_SEN TK10_2_SEN TK9_1_SEN_ TK8_0_SEN_


_FAIL _FAIL _FAIL _FAIL _FAIL _FAIL FAIL FAIL

7 6 5 4 3 2 1 0

TK_SCAN_C
SEN_MATCH_LEVEL Reserved TK_BUSY
MPLT

Not Recommended to Use : Data is ready or not? 0 = Complete or Stop


0,1,E,F 1= Proceeding
10
Register – (4)
Register Offset R/W Description Reset Value

TK_INTEN TK_BA+0x20 R/W Touch Key Interrupt Enable Register 0x0000_0000

31 30 29 28 27 26 25 24

Reserved

23 22 21 20 19 18 17 16

Reserved

15 14 13 12 11 10 9 8

Reserved

7 6 5 4 3 2 1 0
TK_SCAN_
TK_SEN_ TK_SCAN_
Reserved CMPLT_THC
FAIL_IE CMPLT_IE
_IE

1. Touch Key Sensing Fail


2. Touch Key Scan Complete w/o Threshold Control
3. Touch Key Scan Complete with High/Low Threshold Control
11
Register – (5)
Register Offset R/W Description Reset Value

TK8_0_THC TK_BA+0x24 R/W TK8/TK0 Threshold Control Register 0x0000_0000

31 30 29 28 27 26 25 24

TK8_0_HIGH_THC[15:8]

23 22 21 20 19 18 17 16

TK8_0_HIGH_THC[7:0]

15 14 13 12 11 10 9 8

TK8_0_LOW_THC[15:8]

7 6 5 4 3 2 1 0

TK8_0_LOW_THC [7:0]

1. Interrupt will assert whenever TK8_0_DATA is


greater than TK8_0_HIGH_THC
2. Interrupt will assert whenever TK8_0_DATA is
less than TK8_0_LOW_THC
12
Sensitivity Adjustment
• Counter depth
• Increase the depth can improve sensitivity but it takes more
time to scan each channel.
• Charge current level
• Charge current level  ()→ Base level  ()
• Time-Base Clock Frequency

What to do if happening “sensing fail”?


1. Decrease Time-Base Clock Frequency
2. Increase Charge current level

Check TK_STAT [SEN_MATCH_LEVEL] value !!!


13
LIBTK
• Supports three different types of component, key,
slider, and rotor.
• Slider and rotor can be composite with 4~16 touch key
channels
• A key component is composite with 1 channel
• Supports up to 16 components
• Supports configurable resolution for slider and rotor

14
Library (Config.c)
libtk_channel_config_s cfg[TK_CH_NUM] =
{
{0x0000, 0x0000, 1, 0},
{0x0000, 0x0000, 1, 0},
{0x0000, 0x0000, 1, 0},
{0x0000, 0x0000, 1, 0},
{0x0000, 0x0000, 1, 0}, Dummy value must be given even
{0x0000, 0x0000, 1, 0},
{0x965f, 0x0d69, 7, 3}, some channels are not used.
{0x949e, 0x13d3, 7, 3},
{0x0000, 0x0000, 1, 0},
{0x0000, 0x0000, 1, 0},
{0x0000, 0x0000, 1, 0},
{0xabd3, 0x0cf5, 7, 3},
{0xa7c8, 0x0e62, 7, 3},
{0xa49d, 0x0c8b, 7, 3},
{0xa590, 0x0dd5, 7, 3},
{0xa86f, 0x0d02, 7, 3}
};

15
Touch Key AP
Current Status Settings Interface Selection

Configuration

Start

Real-Time Data

16
How to start to use Touch Key AP
1. Download “TKAP_UART” or “TKAP_USB” to Nu-LB-Nano130
or NuTouch
2. Install “NuvoTon-TK-Driver.msi”
3. Execute “Touch_Key_Progarm.exe” and choose the
corresponding interface (USB,UART)
4. Press “Read Device” to get the current status of each channel
5. Choose the wanted channel and press “Start” to monitor the
real-time data of each channel

17
Step 1. Download “TK_USB” Code

NuMicro NANO100B
NANO100BSeriesBSP_CMSIS_V1.00.005 Document Driver Reference Guide

Sample

NuTouch

TK_APP

Firmware

TKAP_USB

TKAP_USB.uvproj
KEIL

18
Step 2. Driver Installation

NuMicro NANO100B
NANO100BSeriesBSP_CMSIS_V1.00.005 Document Driver Reference Guide

Sample

NuTouch

TK_APP

application Touch_Key_Program.exe
Windows_APP

Binary

NuvoTon-TK-Driver.msi
driver

19
Step 3 & 4. TK Application
Current Status
Select USB

Read Device

20
Step 5. Monitor Real-Time Data
Channel 7

Channel 6

Channel 15 ………… Channel 11

Finger on
Channel 6 or Channel 7
21
Auto Config via TK_AP
1. Select one channel and double click to monitor the
information
2. Press “Auto Config”
3. Keep finger away from channel #
4. Put Finger on channel #
5. Channel # Config Success
6. Write Device

22
Step 1. Select Channel 6

Channel 6
Double Click Data
Channel 6

23
Step 2,3,4 & 5. Auto Config

Press
Auto Config

24
Step 6. Write Device

Before After
Channel BASE DIFF DIV CUR Channel BASE DIFF DIV CUR
6 0x9d3e 0x00e8 3 7 6 0x9f3e 0x3fb1 3 7
25
Q&A

26

Вам также может понравиться