完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
第一次调CH579里面的Touch-Key,用的TKY_CH579库,有没有哪位大神用过,教教我调试的时候从哪一步开始调起?为啥我算的充电时间(0x25),跟平稳时达到3000的充电时间(0x60)差这么多啊?
大家使用这个TKY_CH579时,初始化都是怎么处理的?没有出现过上电基线值下降浮动导致触发按键任务的情况吗?急问!!! |
|
相关推荐
4个回答
|
|
/* 配置TouchKey功能检测 */
TKY_BaseInitStructure.filterMode = FILTER_MODE_2; TKY_BaseInitStructure.filterGrade = 4; TKY_BaseInitStructure.maxQueueNum = MAX_QUEUE_NUM; TKY_BaseInitStructure.baseRefreshOnPress = 0; //---基线更新速度,baseRefreshSampleNum和filterGrade,与基线更新速度成反比,基线更新速度还与代码结构相关,可通过函数GetCurQueueBaseLine来观察--- TKY_BaseInitStructure.baseRefreshSampleNum = 250; TKY_BaseInitStructure.baseUpRefreshDouble = 0; TKY_BaseInitStructure.baseDownRefreshSlow = 1000; TKY_BaseInitStructure.tkyBufP = tkyBuf; TKY_BaseInit(TKY_BaseInitStructure); //--------对触摸通道7进行初始化,并列为检测队列中第1位---------- GPIOA_ModeCfg(GPIO_Pin_2, GPIO_ModeIN_Floating); TKY_ChannelInitStructure.queueNum = 0; TKY_ChannelInitStructure.channelNum = 7; TKY_ChannelInitStructure.threshold = 200; TKY_ChannelInitStructure.threshold2 = 150; TKY_ChannelInitStructure.chargeTime = 0x0B; TKY_ChannelInitStructure.baseLine = TKY_GetCurChannelMean(TKY_ChannelInitStructure.channelNum, TKY_ChannelInitStructure.chargeTime, 10000); TKY_CHInit(TKY_ChannelInitStructure); //--------对触摸通道10进行初始化,并列为检测队列中第2位---------- GPIOA_ModeCfg(GPIO_Pin_6, GPIO_ModeIN_Floating); TKY_ChannelInitStructure.queueNum = 1; TKY_ChannelInitStructure.channelNum = 10; TKY_ChannelInitStructure.threshold = 200; TKY_ChannelInitStructure.threshold2 = 150; TKY_ChannelInitStructure.chargeTime = 0x0A; TKY_ChannelInitStructure.baseLine = TKY_GetCurChannelMean(TKY_ChannelInitStructure.channelNum, TKY_ChannelInitStructure.chargeTime, 10000); TKY_CHInit(TKY_ChannelInitStructure); 提供的Touch LIB是完整的工程,可以直接烧进去跑一下,不过默认用的2个通道是PA2 和PA6,如果用其他通道,参考上图加就行或者参考 这个PDF的说明添加通道即可。 你的问题不是特别清楚,可以先用默认参数,测一下通道不按的时候的采样值和按下时测试的通道采样值。先排除硬件问题 用这个函数可以获取通道的测量值,打印看下,可以贴出来 |
|
|
|
感谢您的技术支持以及回复,我现在按照例程跑一个按键是可以的,每次按键按下与不按下时测量值差100以上,见图1。但是使用FILTER_MODE_2跑5个按键用同样的配置,基线差距好大见图2。
图1 图2 请问调试的时候要5个 按键一起调吗? TKY_BaseInitStructure.baseRefreshOnPress = 0; TKY_BaseInitStructure.baseRefreshSampleNum = 250; TKY_BaseInitStructure.baseUpRefreshDouble = 0; TKY_BaseInitStructure.baseDownRefreshSlow = 1000; TKY_ChannelInitStructure.threshold = 200; TKY_ChannelInitStructure.threshold2 = 150; TKY_ChannelInitStructure.chargeTime = 0x0B; 以上这些参数的配置要获取通道的测量值达到什么效果才算好哪?调试时,以上参数配置的优先级是怎样哪?比如我是先调试配置threshold的值还是先调试配置threshold2的值? |
|
|
|
我今天调试的时候,发现一个问题,请各位大神解答一下。
以下是我调试的代码: /* 配置TouchKey功能检测 */ TKY_BaseInitStructure.filterMode = FILTER_MODE_2; TKY_BaseInitStructure.filterGrade = 4; TKY_BaseInitStructure.maxQueueNum = MAX_QUEUE_NUM; TKY_BaseInitStructure.baseRefreshOnPress = 0; //---基线更新速度,baseRefreshSampleNum和filterGrade,与基线更新速度成反比,基线更新速度还与代码结构相关,可通过函数GetCurQueueBaseLine来观察--- TKY_BaseInitStructure.baseRefreshSampleNum = 250; TKY_BaseInitStructure.baseUpRefreshDouble = 0; TKY_BaseInitStructure.baseDownRefreshSlow = 1000; TKY_BaseInitStructure.tkyBufP = tkyBuf; TKY_BaseInit(TKY_BaseInitStructure); //--------对触摸通道7进行初始化,并列为检测队列中第1位---------- GPIOA_ModeCfg(GPIO_Pin_3, GPIO_ModeIN_Floating); TKY_ChannelInitStructure.queueNum = 0; TKY_ChannelInitStructure.channelNum = 6; TKY_ChannelInitStructure.threshold = 200; TKY_ChannelInitStructure.threshold2 = 200; TKY_ChannelInitStructure.chargeTime = 0x0B;//0x25;//0x0B; TKY_ChannelInitStructure.baseLine = TKY_GetCurChannelMean(TKY_ChannelInitStructure.channelNum, TKY_ChannelInitStructure.chargeTime, 10000); current_base_line[0] = TKY_ChannelInitStructure.baseLine;//获取当前基线值 TKY_CHInit(TKY_ChannelInitStructure); // current_base_line[0] = TKY_GetCurQueueBaseLine(0); //--------对触摸通道8进行初始化,并列为检测队列中第2位---------- GPIOA_ModeCfg(GPIO_Pin_1, GPIO_ModeIN_Floating); TKY_ChannelInitStructure.queueNum = 1; TKY_ChannelInitStructure.channelNum = 8; TKY_ChannelInitStructure.threshold = 200;//20;//15; // TKY_ChannelInitStructure.threshold2 = 200;//17;//10; // TKY_ChannelInitStructure.chargeTime = 0x0B;//0x30;//0x25; TKY_ChannelInitStructure.baseLine = TKY_GetCurChannelMean(TKY_ChannelInitStructure.channelNum, TKY_ChannelInitStructure.chargeTime, 10000);//0x943;// current_base_line[1] = TKY_ChannelInitStructure.baseLine;//获取当前基线值 TKY_CHInit(TKY_ChannelInitStructure); // current_base_line[1] = TKY_GetCurQueueBaseLine(1); //--------对触摸通道9进行初始化,并列为检测队列中第3位---------- GPIOA_ModeCfg(GPIO_Pin_0, GPIO_ModeIN_Floating); TKY_ChannelInitStructure.queueNum = 2; TKY_ChannelInitStructure.channelNum = 9; TKY_ChannelInitStructure.threshold = 200;//20;//15; // 主要是更改这个值来进行相应的触摸体验。 TKY_ChannelInitStructure.threshold2 = 200;//17;//10; // TKY_ChannelInitStructure.chargeTime = 0x0B;//0x30;//0x25; TKY_ChannelInitStructure.baseLine = TKY_GetCurChannelMean(TKY_ChannelInitStructure.channelNum, TKY_ChannelInitStructure.chargeTime, 10000);//0x949;// current_base_line[2] = TKY_ChannelInitStructure.baseLine;//获取当前基线值 TKY_CHInit(TKY_ChannelInitStructure); //current_base_line[2] = TKY_GetCurQueueBaseLine(2); //--------对触摸通道10进行初始化,并列为检测队列中第4位---------- GPIOA_ModeCfg(GPIO_Pin_6, GPIO_ModeIN_Floating); TKY_ChannelInitStructure.queueNum = 3; TKY_ChannelInitStructure.channelNum = 10; TKY_ChannelInitStructure.threshold = 200;//12; //200 10 12 TKY_ChannelInitStructure.threshold2 = 200;//10;//3; //150 TKY_ChannelInitStructure.chargeTime = 0x0B;//0x30;//0x25; TKY_ChannelInitStructure.baseLine = TKY_GetCurChannelMean(TKY_ChannelInitStructure.channelNum, TKY_ChannelInitStructure.chargeTime, 10000);//0x92C;// current_base_line[3] = TKY_ChannelInitStructure.baseLine;//获取当前基线值 TKY_CHInit(TKY_ChannelInitStructure); //current_base_line[3] = TKY_GetCurQueueBaseLine(3); //--------对触摸通道11进行初始化,并列为检测队列中第5位---------- GPIOA_ModeCfg(GPIO_Pin_7, GPIO_ModeIN_Floating); TKY_ChannelInitStructure.queueNum = 4; TKY_ChannelInitStructure.channelNum = 11; TKY_ChannelInitStructure.threshold = 200;//25; TKY_ChannelInitStructure.threshold2 = 200;//10;//5; //150 TKY_ChannelInitStructure.chargeTime = 0x0B;//0x30;//0x25; TKY_ChannelInitStructure.baseLine = TKY_GetCurChannelMean(TKY_ChannelInitStructure.channelNum, TKY_ChannelInitStructure.chargeTime, 10000);//0x8E6;// current_base_line[4] = TKY_ChannelInitStructure.baseLine;//获取当前基线值 TKY_CHInit(TKY_ChannelInitStructure); //current_base_line[4] = TKY_GetCurQueueBaseLine(4); /*打印配置时的基线值*/ PRINT("current base line1 = %04drn",current_base_line[0]); PRINT("current base line2 = %04drn",current_base_line[1]); PRINT("current base line3 = %04drn",current_base_line[2]); PRINT("current base line4 = %04drn",current_base_line[3]); PRINT("current base line5 = %04drn",current_base_line[4]); mDelaymS(300);//延时300Ms PRINT("delay 300ms rn"); /*重新获取基线值*/ for(int i=0;i<5;i++) { current_base_line = TKY_GetCurQueueBaseLine(i); mDelaymS(5); } PRINT("current base line1 = %04drn",current_base_line[0]); PRINT("current base line2 = %04drn",current_base_line[1]); PRINT("current base line3 = %04drn",current_base_line[2]); PRINT("current base line4 = %04drn",current_base_line[3]); PRINT("current base line5 = %04drn",current_base_line[4]); 请问是哪里的问题,导致基线值在这么短的时间内发生这么大的变化? |
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
477 浏览 1 评论
CH579M+RT-Thread,RTC从Sleep模式唤醒失败是什么原因?
2874 浏览 2 评论
2361 浏览 1 评论
818浏览 2评论
CH569通过HSPI实现USB3.0和FPGA高速双向通讯
645浏览 1评论
500浏览 1评论
CH32F103C8T6使用当前官网上的CDC例程会出现设备描述符请求失败
365浏览 1评论
642浏览 1评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-26 19:36 , Processed in 1.297172 second(s), Total 82, Slave 66 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号