6595 views|1 replies

50

Posts

0

Resources
The OP
 

ch554 review: 1. Development environment learning and TouchKey self-capacitance key detection [Copy link]

This post was last edited by iceriver on 2017-11-29 16:21
1. Unboxing photos
Figure 1: Unboxing photos
2. Initial test of the development board
The power supplies of several USB interfaces are connected together, and the power is provided through the computer USB interface. At this time, the jumper shorts JP1's 4th and 6th pins, 3rd and 5th pins, and the microcontroller UART0 is connected to the ch340 chip to provide serial communication function
Figure 2: Default jumper position 332009 3. Install the ch340 driver. The computer did not automatically recognize the serial port after power-on. I downloaded the ch340 driver from Qinheng’s official website. After installing the driver, I changed it to serial port 6 (as shown in Figure 3). At this time, the data uploaded by the factory program can be read through the serial assistant (as shown in Figure 4)
Figure 3: Serial driver installed
[attach]332010 [/attach]
Figure 4: Screenshot of serial communication of default program
[attach]332011 [/attach]
4, Program burning experiment
There are two ways to burn, one is to burn through the serial port, and the other is to burn through USB. When burning through the serial port, the USB is connected to the computer through P1, and the jumper shorts the 10th and 8th pins, 9th and 7th pins of JP1, as shown in Figure 5; the software settings are shown in Figure 6. When downloading through USB, it is connected to the computer through the P2 port, regardless of the jumper position, and the software settings are shown in Figure 7. No matter which download method is used, you need to press and hold the download button in advance and release it after power-on to achieve normal downloading.
Figure 5: Serial port burning jumper position
Figure 6: Serial port download successful
Figure 7: USB download successful
5. TouchKey experiment
I only know the knowledge related to self-capacitance. CH554 has 6 IOs that can detect capacitance changes (as shown in Figure 8). In the self-capacitance mode, each pin detects its capacitance change separately. Since the two buttons K1 and K2 of the development board are connected to two pins, my experiment did not program them, that is, only the two channels P14 (TIN2) and P15 (TIN3) were detected.
Since only the capacitance of the two channels P14 and P15 is detected, the macro definition during initialization is modified as follows, and the microcontroller uses the query method to detect whether the button is pressed, without software filtering, and the detection threshold is increased to 50. P1_DIR_PU &= 0xC0; #define KEY_FIRST 2 #define KEY_LAST 3 #define KEY_ACT 50 #define INTERRUPT_TouchKey 0 This is my query detection function: void TouchKeyChannelQuery(){ UINT8 ch = 0; UINT16 KeyData; TKEY_CTRL = TKEY_CTRL & 0xF8 | KEY_FIRST + 1 ; //Start sampling TIN2 from the first channel while((TKEY_CTRL&bTKC_IF) == 0); //When bTKC_IF becomes 1, the sampling of this cycle is completed KeyData = TKEY_DAT&0x07F0; //Keep for 87us,Take it away as soon as possible
// ch = TKEY_CTRL&7; //Get the current sampling channel
if ( KeyData < (KeyFree[KEY_FIRST] - KEY_ACT) ) //If the condition is met, it means the key is pressed
{
KeyBuf= KEY_FIRST ; //You can process the key action here or set a flag to notify main to process
}
TKEY_CTRL = TKEY_CTRL & 0xF8 | KEY_LAST +1 ; //Start sampling TIN3 from the first channel
while((TKEY_CTRL&bTKC_IF) == 0); //When bTKC_IF becomes 1, the sampling of this cycle is completed
KeyData = TKEY_DAT&0x07F0; //Hold for 87us, remove as soon as possible
// ch = TKEY_CTRL&7; //Get the current sampling channel
if ( KeyData < (KeyFree[KEY_LAST] - KEY_ACT) ) //If the condition is met, it means the key is pressed
{
KeyBuf= KEY_LAST ; //You can process the key action here or set a flag to notify main to process
}
}
Figure 8: CH554 touch capacitance detection channel
Figure 9: Development board touch button connection method
Figure 10: Screenshot of touch button reception 332017 332017 [/attach] This content is created by EEWORLD forum user iceriver. If you need to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source.0pt]Figure 8: CH554 touch capacitance detection channel
Figure 9: Development board touch button connection method
Figure 10: Touch button receiving screenshot
This content is originally created by EEWORLD forum user iceriver. If you want to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source0pt]Figure 8: CH554 touch capacitance detection channel
Figure 9: Development board touch button connection method
Figure 10: Touch button receiving screenshot
This content is originally created by EEWORLD forum user iceriver. If you want to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source

默认跳线位置.png (1.97 MB, downloads: 0)

图2:默认跳线位置

图2:默认跳线位置

串口驱动安装好.png (7.06 KB, downloads: 0)

图3:串口驱动安装好

图3:串口驱动安装好

默认程序串口通讯.png (9.09 KB, downloads: 0)

图4:默认串口通讯

图4:默认串口通讯
This post is from MCU

Latest reply

  Details Published on 2017-11-30 09:26
 

305

Posts

0

Resources
2
 
This post is from MCU
 
Personal signature单价1元含税的USB和Touchkey单片机CH551G已大批量出货,试样QQ:1258305301
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list