Contents

  • Abstract
  • 一、Development tools
  • 二、Create PSoC Project
  • 三、PSoC Project Configuration
  • 四、PSoC Programmer
  • 五、Tuner Communication
  • 六、Communication Between GD32F303 And PSoC4000
    • (1)PSoC4000 Configuration
    • (2)GD32F303 Configuration
  • Summary

Abstract

  CapSense technology is more and more popular in the product design of mobile devices、personal computer、consumer electronics、auto industry and major appliance. It is more reliable and easily use than traditional Mechanical keys.Meanwhile, Cypress provide a series of solution, you can get started quickly,Using flexible, reduce development cycles Significantly.Get more details information through Cypress website.
  In this article, you can get methods that the configuration of PSoC project、CapSense parameters calibration、establish communication to GD32.
Key words: Create PSoC Project 、PSoC Programmer 、Tuner、GD32 、IIC


一、Development tools

  1.Chip:CY8C4014LQI-422
  2.Downloader:CYPRESS MiniProg3
  3.Compiler:PSoC Creator 4.4
  4.Download Software:PSoC Programmer 3.29.1


二、Create PSoC Project

  1.Launch PSoC Creator 4.4, 【File】 — 【New】 — 【Project】

  2.Select project type, 【PSoC 4】 — 【CY8C4014LQI-422】 — 【Next】

  3.Select project template, 【Enpty schematic】 — 【Next】

  4.Create Project,【Finish】


三、PSoC Project Configuration

  1.Add 【EZI2C Slave (SCB mode) [v4.0]】, select and drag it to 【TopDesign.cysch】 work space:

  2.Configure the EZI2C, double-click the EZI2C module and Configure it as follow picture:

  Note: You can get more details about parameters through Datasheet

  3.Add CapSense [v7.0], select and drag it out to 【TopDesign.cysch】 work space:

  4.Configure CapSense, double-click the CapSense module and Configure it as follow picture:
  【Basic】

  【Advanced 】 — 【General 】

  【Advanced 】 — 【CSD Settings】

  【Advanced 】 — 【Widget Details】

  Sense clock frequency:It is recommended to set maximum value.
  Scan resolution:The higher the value, the more sensitive it is.Set the value fallow the system need.
  Finger threshold:It is recommended to set the Finger threshold parameter value equal to the 80% of the touch signal.
  Noise threshold:It is recommended to set the noise threshold parameter value equal to 2x noise in the raw count or the 40% of the signal.
  Negative noise threshold:It is recommended to set the negative noise threshold parameter value equal to the Noise threshold parameter value.
  Low baseline reset:The recommended value is 30, which works for most designs.
  Hysteresis:The recommend value for the hysteresis is the 10% Finger threshold.
  ON debounce:The recommended value for the Debounce parameter is 3 for reliable sensor status detection.

  5.Configure Pins & System

  【Design Wide Resources】 — 【Pins】

  【Design Wide Resources】 — 【System】 — 【Debug Select】 — 【GPIO】

  6.Build project

  7.Add your code in【main.c】

int main ()
{    /* Enable Global interrupts for CapSense operation */CyGlobalIntEnable;/* Start EZI2C block */EZI2C_Start();/* Set up communication data buffer to CapSense data structure to be exposed to I2C master at primary slave address request. */EZI2C_EzI2CSetBuffer1(sizeof(CapSense_dsRam), sizeof(CapSense_dsRam), (uint8 *)&CapSense_dsRam);/* Start CapSense block - Initializes CapSense Data structure and performs first scan to set up sensor baselines */CapSense_Start();/* Scan all widgets */CapSense_ScanAllWidgets();for(;;){/* Do this only when a scan is done */if(CapSense_NOT_BUSY == CapSense_IsBusy()){/* Process all widgets */CapSense_ProcessAllWidgets();/* Include Tuner */ CapSense_RunTuner(); /* Scan result verification */if (CapSense_IsAnyWidgetActive()){/* Add any required functionalitybased on scanning result*/}/* Start next scan */CapSense_ScanAllWidgets();}}
}

  8.Clean and build the program, plug MiniProg3
  Note: When I Connected PSoc 4000 with MiniProg3,it would fail to Program if I don’t exchange the wire of SDAT and SCLK


四、PSoC Programmer

  1.Launch PSoC Programmer 3.29.1

  2.Select 【Device Family】 and 【Device】

  3.Load HEX file, HEX file relative path: \CortexM0\ARM_GCC_541\Debug

  4.Connect

  5.Programming Mode, Select 【Reset】 if you use external power, Select 【Power Cycle】 if you use MiniProg3 to provide power

  6.Programming

  7.Disconnect, Release I2C


五、Tuner Communication

  1.Launch Tuner

  2.Tuner Communication Setup


  3.【Connect】 — 【Start】

  4.【xxx FT】、【xxx NT】、【xxx H】 Calibration

Note: touch the CapSense , observe the response of signal, change this value for your need.

  5.Acquire Noise & Signal



  Note: make sure SNR is more than 5:1 that is optimal.


六、Communication Between GD32F303 And PSoC4000

(1)PSoC4000 Configuration

  1.Open above project,Configure 【EZI2C】

  Note: Primary slave address (7-bits) is the 7-bit right-justified slave address and does not include the R/W bit. You can refer to Datasheet in page 64.
  2.【Design Wide Resources】 — 【System】 — 【Debug Select】 — 【SWD(serial wire debug)】

  3.【Design Wide Resources】 — 【Pins】, select the IIC port to GD32

  4.Build project

  5.Add your code in【main.c】

#define buffer_rw_boundary (0x04u)
static ezi2c_t Data_buf;
static uint8_t ButtonStatus = 0;int main ()
{    /* Enable Global interrupts for CapSense operation */CyGlobalIntEnable;/* Start EZI2C block */EZI2C_Start();/* Set up communication data buffer to CapSense data structure to be exposed to I2C master at primary slave address request. */EZI2C_EzI2CSetBuffer1(sizeof(Data_buf),buffer_rw_boundary ,(uint8*)&Data_buf);/* Start CapSense block - Initializes CapSense Data structure and performs first scan to set up sensor baselines */CapSense_Start();/* Scan all widgets */CapSense_ScanAllWidgets();for(;;){/* Do this only when a scan is done */if(CapSense_NOT_BUSY == CapSense_IsBusy()){/* Process all widgets */CapSense_ProcessAllWidgets();ButtonStatus = 0;//ID refer to CapSense_Configuration.hif(CapSense_IsWidgetActive(CapSense_ESPRESSO_WDGT_ID)){ButtonStatus |= (1 << 0);}if(CapSense_IsWidgetActive(CapSense_LUNGO_WDGT_ID)){ButtonStatus |= (1 << 1);}if(CapSense_IsWidgetActive(CapSense_X_LUNGO_WDGT_ID)){ButtonStatus |= (1 << 2);}if(CapSense_IsWidgetActive(CapSense_CAPPUCINO_WDGT_ID)){ButtonStatus |= (1 << 3);}if(CapSense_IsWidgetActive(CapSense_LATTE_WDGT_ID)){ButtonStatus |= (1 << 4);}if(CapSense_IsWidgetActive(CapSense_HOT_WATER_WDGT_ID)){ButtonStatus |= (1 << 5);}if(CapSense_IsWidgetActive(CapSense_RINGE_WDGT_ID)){ButtonStatus |= (1 << 6);}/* Start next scan */CapSense_ScanAllWidgets();  }}
}

  6.Clean and build the program, use 【PSoC Programmer 3.29.1 】to download the program

(2)GD32F303 Configuration

  1.Download 【GD32F30x Firmware Library】【GD32F30x User Manual】

  2.This Firmware is builded by Keil4, you must change the project name before open it with Keil5. Change 【Project.uvproj】to 【Project.uvprojx】

  3.Select your device

  4.Select debug mode.I use GD-Link to debug, so I select CMSIS-DAP Debugger

  5.Add programming Algorithm

  6.Build Project

  7.Remap I2C0. I2C0 default in PB6 and PB7, refer to GD32F30x User Manual Page 177 and 190, So we must remap it.

void clock_init(void)
{rcu_periph_clock_enable(RCU_GPIOB);rcu_periph_clock_enable(RCU_I2C0);  rcu_periph_clock_enable(RCU_TIMER0);rcu_periph_clock_enable(RCU_AF);gpio_pin_remap_config(GPIO_I2C0_REMAP,ENABLE);
}

  8.Init I2C0

void I2C0_INIT(void)
{ gpio_init(GPIOB, GPIO_MODE_AF_OD, GPIO_OSPEED_50MHZ, GPIO_PIN_8 | GPIO_PIN_9);i2c_clock_config(I2C0, 100000, I2C_DTCY_2);i2c_mode_addr_config(I2C0, I2C_I2CMODE_ENABLE, I2C_ADDFORMAT_7BITS, slave_add);i2c_enable(I2C0);i2c_ack_config(I2C0, I2C_ACK_ENABLE);
}

  slave_add is PSoC4000 address, refer to 【 PSoC4000 Configuration 】,you must move 1 bit to the right

  9.I2C0 receive function

uint8_t Read_Touch_signal(uint16_t SlaveAdd,uint8_t *ReadByte)
{uint8_t err = 1;/* wait until I2C bus is idle */while(i2c_flag_get(I2C0, I2C_FLAG_I2CBSY));/* send a start condition to I2C bus */i2c_start_on_bus(I2C0);/* wait until SBSEND bit is set */while(!i2c_flag_get(I2C0, I2C_FLAG_SBSEND));/* send slave address to I2C bus */i2c_master_addressing(I2C0, SlaveAdd, I2C_RECEIVER);/* wait until ADDSEND bit is set */while(!i2c_flag_get(I2C0, I2C_FLAG_ADDSEND));/* clear ADDSEND bit */i2c_flag_clear(I2C0, I2C_FLAG_ADDSEND);/* wait until the second last data byte is received into the shift register */while(!i2c_flag_get(I2C0, I2C_FLAG_BTC));/* disable acknowledge */i2c_ack_config(I2C0, I2C_ACK_DISABLE);/* wait until the RBNE bit is set */while(!i2c_flag_get(I2C0, I2C_FLAG_RBNE));/* read a data from I2C_DATA */*ReadByte  = i2c_data_receive(I2C0);/* send a stop condition to I2C bus */i2c_stop_on_bus(I2C0);/* wait until stop condition generate */while(I2C_CTL0(I2C0)&0x0200);/* enable acknowledge */i2c_ack_config(I2C0, I2C_ACK_ENABLE);err = 0;return err;
}

  Note: You can program function refer to firmware example


Summary

  It is my first time to write a blog with English, you can leave a message to inform me if there are any error or unclear expression.Thanks a lot !

Cypress(赛普拉斯)电容式感应(CapSense)触摸按键应用笔记(工程配置+功能调校+IIC通讯)相关推荐

  1. 4 命名规则_赛普拉斯(Cypress)存储器芯片命名规则

    1,前言 赛普拉斯(Cypress)公司是一家知名的电子芯片制造商.赛普拉斯在纽约股票交易所上市,在数据通信.消费类电子等广泛领域均提供芯片解决方案. 2020年4月16日赛普拉斯(Cypress)和 ...

  2. cypress离线安装_新思、敦泰、汇顶/赛普拉斯触控ICD万能脱机烧录测试工具TP-TEST...

    触摸屏脱机烧测工具TP-TESTER产品介绍TP-TESTER是深圳康协利http://www.comshare-sz.com(Comshare)针对触摸屏行业而研发的一款通用型触摸屏生产测试设备.相 ...

  3. 赛普拉斯CYpress,初接触之一电磁感应触摸按键demo

    背景 刚到新公司,新公司接收了一个新的项目,要求使用赛普拉斯芯片,头一次用,而且是图形界面+程序方式,有点python QT界面制作然后自动生成代码的感觉,难道这是未来的开发趋势,为了工作没办法,搞吧 ...

  4. 非常实用: 2.4G天线设计指南(赛普拉斯工程师力作)

    转载来源:[射频百花潭]<非常实用: 2.4G天线设计指南(赛普拉斯工程师力作)> 本文章使用简单的术语介绍了天线的设计情况,并推荐了两款经过赛普拉斯测试的低成本PCB天线.这些PCB天线 ...

  5. 赛普拉斯 12864_如何使用赛普拉斯自动化辅助功能测试

    赛普拉斯 12864 In my previous post, I covered how to add screenshot testing in Cypress to ensure compone ...

  6. 外媒:美国政府官员建议阻止英飞凌收购赛普拉斯

    3月7日消息,据国外媒体报道,知情人士透露,美国国家安全官员建议总统阻止英飞凌对赛普拉斯半导体(Cypress Semiconductor,以下简称赛普拉斯)的收购计划. 知情人士称,美国政府官员们担 ...

  7. 赛普拉斯PSoC6正式接入阿里云Link TEE加强物联网应用的安全设计...

    中国北京,2019年4月15日 - 全球领先的嵌入式解决方案供应商赛普拉斯半导体公司(Cypress Semiconductor Corp.)(纳斯达克代码:CY)今日宣布,旗下物联网计算和无线解决方 ...

  8. 赛普拉斯天线_赛普拉斯在gitlab ci管道中设置了首次验收测试

    赛普拉斯天线 Late evening calls, reverted releases, lost revenue, and eventually fear of touching anything ...

  9. 半导体重磅!英飞凌宣布100亿美元收购赛普拉斯

    [TechWeb]本月半导体行业可以说是动作频频, 继恩智浦以17.6 亿美元收购Marvell 的Wi-Fi 和蓝牙芯片组合业务之后,又迎来半导体行业的另一大并购.6月3日, 德国半导体厂商英飞凌宣 ...

最新文章

  1. 高级 Linux 命令精通指南
  2. 使用分页插件的后悔药(二)
  3. 微信 php post json,微信企业号:如何POST JSON数据发送消息给企业号成员
  4. python 图表 web_Web | Django 与 Chart.js 联用做出精美的图表
  5. 版本不一致_一致哈希:Beyond the basics
  6. Centos7利用fpm制作rpm包(fpm安装及使用)
  7. Python中BufferedIOBase
  8. 寻求生态保护与矿产开发平衡点 青海给出“绿色方案”
  9. MySQL双主机双Master方案测试
  10. return的用法 java_Java中return用法.
  11. 华为交换机开启ftp服务,上传和下载文件,get和put操作实例
  12. python安装包————————百度网盘
  13. 谷歌浏览器如何自动运行flash
  14. linux更换steam目录,终于可以在Linux上愉快地玩耍Steam啦
  15. 如何编译 cm12 (for 一加手机)
  16. 手记---道可道,非常道
  17. 给定divId,滚动条滚到相应位置
  18. 如何比较两个文本的相似度
  19. QT学习记录 --- 获取文件哈希值
  20. 澤山咸 (易經大意 韓長庚)

热门文章

  1. (二)分布式系统-Introduction to Distributed Systems
  2. 看清商业本质的若干欧美经典之电影篇------很赞的电影,值得一看,顺便转过来...
  3. Redis的PHP客户端rediska、phpredis、Predis介绍
  4. 传统算法与神经网络算法,神经网络算法包括哪些
  5. [转]爆肝一周,完成了一款第一人称3D射击游戏,现在把源代码分享给大家,适合新手跟着学习
  6. Springcloud五大神兽流程图
  7. 解决Rtools3.5下载R包速度特慢的问题
  8. 多位点序列分型_细菌多位点序列分型(Multilocus sequence typing,MLST)的原理及分型方法...
  9. Hbase查询数据的总条数
  10. 承接机器视觉项目到底应该选哪个解决方案?传统机器视觉 vs 人工智能