Code Examples Forum Discussions
Hello,
This is a sample code for wakeup from DeepSleep using UART for CY8CKIT-145-40XX.
However, it is woken up by GPIO interrupt.
You need to have 4 pull-up resistors shown in blue wiring.
[How to operate]
Set the terminal software of your PC as follows.
- Into DeepSleep mode
If you send data with the terminal software after pressing SW2, it will be in Deep Sleep mode.
- Wake up from DeepSleep mode
It wakes up when you send data from the terminal software while in DeepSleep mode.
When 0x00 data is received, it wakes up, but the data does not enter the receive buffer.
When it receives anything other than 0x00 data, it wakes up, but the data in the receive buffer is unreliable.
Best regards,
Yocchi
Show LessHi,
This is a simple sample of using CapSense [v7.0] for 2 buttons operation using CY8CKIT-042.
Although this is a quite simple sample, may be somewhat useful for those who is not familiar with writing C program(s),
such as the discussion below.
I assigned the node P1.5 as "Up" button and P1.1 as "Down" button.
schematic
CapSense Config
Pins
Since I don't have many LEDs on my CY8CKIT-042,
I let UART write "*" instead of LEDs.
main.c
==========================
#include "project.h"
#include "stdio.h"
#define MAX_LED_COUNT 4
#define MIN_LED_COUNT 0
#define STR_BUF_LEN 32
char str[STR_BUF_LEN+1] ;
void print(char *str)
{
UART_PutString(str) ;
}
void cls(void)
{
print("\x1b[2J\x1b[;H") ;
}
void init_hardware(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
UART_Start() ;
cls() ;
CapSense_Start() ;
CapSense_ScanAllWidgets() ;
}
void do_led(int led_count)
{
switch(led_count) {
case 0: /* MIN_LED_COUNT? */
/* turn off all LEDs */
cls() ;
break ;
case 1:
/* turn on only 1 LED */
cls() ;
print("*\n\r") ;
break ;
case 2:
/* turn on 2 LEDs */
cls() ;
print("* *\n\r") ;
break ;
case 3:
/* turn on 3 LEDs */
cls() ;
print("* * *\n\r") ;
break ;
case 4: /* MAX_LED_COUNT? */
/* turn on 4 LEDs */
cls() ;
print("* * * *\n\r") ;
break ;
default:
/* do nothing */
break ;
}
}
int main(void)
{
int led_count = 0 ;
init_hardware() ;
for(;;)
{
if (CapSense_NOT_BUSY == CapSense_IsBusy()) {
CapSense_ProcessAllWidgets() ;
if (CapSense_IsAnyWidgetActive()) {
if (CapSense_IsSensorActive(CapSense_BUTTON0_WDGT_ID, CapSense_BUTTON0_SNS0_ID)) {
led_count++ ;
if (led_count > MAX_LED_COUNT) {
led_count = MAX_LED_COUNT ;
}
} else if (CapSense_IsSensorActive(CapSense_BUTTON0_WDGT_ID, CapSense_BUTTON0_SNS1_ID)) {
led_count-- ;
if (led_count < MIN_LED_COUNT) {
led_count = MIN_LED_COUNT ;
}
}
do_led(led_count) ;
}
CyDelay(100) ;
CapSense_ScanAllWidgets() ;
}
}
}
==========================
moto
Show Less
A week or so ago, I posted a sample of directly handling 1602 charLCD.
But there also was a request for a sample using an I2C-LCD module.
So I ordered my modules to Amazon, then noticed that there were very few documentation(s) available for the module,
except Arduino C++ sample.
At first I tried to port the Arduino sample, but the more I tried the more screwed up I was 😜
Today, I realized that the device on the module is PCF8574, which is an I2C - port expander and reading the datasheet it's pretty easy to handle. So I discarded my pasta I've been boiled for a few days and ported my previous program directly using the PCF8574.
Anyway, it seems to be working now.
Schematic
Note: Using the module (and/or CY8CKIT-062-BLE) we don't need external I2C pull-ups.
Although the spec of the I2C module was 5V, it worked OK with 3.3V on my side of the planet.
If you are going to use 5V LCD module and power the I2C-LCD module with 5V,
please use 3.3V for I2C pull up to avoid burning PSoC 6.
(You may need to remove 4.7K pull-ups on the module, which is connected to VCC (=5V))
Pins
Tera Term log (to write "Hello World!" from this program)
moto
[Edit] 12-Mar-2021 fixed a type
Show Less
I am submitting a library for working with character & graphic LCDs. Included are:
Character LCD with more flexible pinning (so I can put one on a Kit-059).
I2C Char LCD using one of the common I2C backpacks.
128 x 64 LCD with ST7920 controller.
132 x 32 LCD with S6B1713 controller (AKA D22-5003 module).
& possibly a component for the common 84 x 48 modules from the Nokia 5110.
Refer to the included readme.txt for further details.
This is my first post & I hope I'm putting it in the right place...
Show LessHello,
Turn the LED on/off using the Cy_CapSense_IsProximitySensorActive () function provided for Proximity based on the Simple Proximity Sensor Demo posted earlier
The previous CE was a program that brightened and darkened the LED according to the distance. When using proximity sensing to turn the switch on and off, it is easy to use the provided Cy_CapSense_IsProximitySensorActive () function.
The program in the main.c file has been changed as follows.
-------------
static void process_touch(void)
{
uint32_t prox_status;
static led_data_t led_data = {LED_ON, LED_MAX_BRIGHTNESS};
prox_status = Cy_CapSense_IsProximitySensorActive (
CY_CAPSENSE_PROXIMITY0_WDGT_ID,
CY_CAPSENSE_PROXIMITY0_SNS0_ID,
&cy_capsense_context);
if((prox_status & 0x3) == 0){
led_data.state=LED_OFF;
}
else
{
led_data.state=LED_ON;
}
update_led_state(&led_data);
}
------------
Please use the one of Simple Proximity Sensor Demo (TARGET_CY8CKIT-062-BLE.zip) for CapSense and peripheral settings. Only the project is attached here.
Thanks,
Kenshow
Hello,
I wanted a simple proximity sensor demo that would work on ModusToolbox, but there isn’t one, so I made one.
The base was based on the CapSense sample for MTB and CE218137.
The environment used is as follows:
・ModusToolbox 2.2.1
・CY8CKIT-062-BLE
The settings of the peripherals (Pin and CapSense) are the same as CE218137, but they are set for ModusToolbox.
First, the CapSense settings are configured in the CapSense Configurator, which is the same as CE218137.
The LED and PWM are set programmatically, as it is using the CapSense sample for ModusToolbox.
The touch process is as follows:
-----------------
static void process_touch(void)
{
static uint32_t currentProxData = 0u;
static led_data_t led_data = {LED_ON, LED_MAX_BRIGHTNESS};
if(CY_CAPSENSE_PROXIMITY0_SNS0_DIFF0_VALUE >
CY_CAPSENSE_PROXIMITY0_FINGER_TH_VALUE)
{
/*If proximity value is not within the range, cap the value */
if((CY_CAPSENSE_PROXIMITY0_SNS0_DIFF0_VALUE -
CY_CAPSENSE_PROXIMITY0_FINGER_TH_VALUE)
<= UINT8_MAX)
{
/* Store the proximity data */
currentProxData = (uint8_t)(CY_CAPSENSE_PROXIMITY0_SNS0_DIFF0_VALUE -
CY_CAPSENSE_PROXIMITY0_FINGER_TH_VALUE);
}
/* Store the maximum value otherwise */
else
{
currentProxData = (uint8_t)UINT8_MAX;
}
}
led_data.brightness = currentProxData;
update_led_state(&led_data);
}
-----------------
CapSense Tuner can be used in this sample, so please use it for fine adjustment.
Thanks,
Kenshow
Show LessHello,
Since I created an ON / OFF switch program using a proximity sensor (Simple Proximity Sensor Demo using Cy_CapSense_IsProximitySensorActive API on PSoC6 for MTB2.2), I made a 7th dice using it. When you bring your hand closer, the dice rotate, and when you move your hand away, it slowly stops. A description of the 7-eyes dice for MTB can be found in Let's make the dice of seven eyes on PSoC 6 with DMA & Beep for ModusToolBox2.2.
As a matter of fact, the proximity sensing program by MTB has created a project with a shared library up to this program, so all BSP settings are common. Therefore, please use the BSP of Simple Proximity Sensor Demo.
The environment used is as follows:
・ModusToolbox 2.2.1
・CY8CKIT-062-BLE
Thanks,
Kenshow
To all,
Here is a new LED matrix driver component. It is highly based on the Cypress/Infineon component of the same type except it extends the number of maximum Commons from 8 to 16.
It uses the Cypress API interface and should be directly compatible to the Cypress component with the following exception:
- The Brightness feature works globally on the entire display whereas the Cypress component allowed for individual Brightness based on the digit position.
Target PSoCs:
- PSoC5 (Tested)
- PSoC4 (Compiled without errors but not tested)
If you find issues with this component, please send me private messages. I will see what I can do to apply a fix.
Show LessI planned this program to show the minimum usage of the basic components of PSoC
and to help testing a new board or peripheral when application is yet to be written.
このプログラムは PSoC を初めて使用する方に基本的なコンポーネントの使い方をお見せするとともに
新しく作った基板や周辺をアプリケーションが出来る前に試せるようにと考えて作ってみました。
More than a couple weeks has passed since I posted CY8CKIT-044 version of this program.
And what I learned during this period is that PSoC 6 is different from PSoC 4!
Anyway, here is the first PSoC 6 version of this program.
このプログラムの CY8CKIT-044 版を投稿してから、既に2週間以上が経ってしまいました。
その間で学んだことは、PSoC 6 は PSoC 4 とは違う!という事でした。
何はともあれ、このプログラムの PSoC 6 用の初版です。
When you build and program or debug, you will see something like below.
Basically the same help message is displayed.
Except the last one and the prompt.
プロジェクトをビルドして書込むかデバッグを開始すると下記のような表示になります。
基本的に前回のものと同じです、
最後の命令とプロンプトを除いては。
Assuming that the E-Ink Shield is mounted on your CY8CKIT-062-BLE.
Enter "i2c" at the prompt.
Now prompt changes to "CM0P:i2c>"
Enter "scan" to scan the I2C bus... it finds a device at 0x68, which is the BMI160 on the E-Ink Shield.
We can read its ID from the register address 0.
So enter "readreg 0", then expected ID of D1 is returned.
CY8CKIT-062-BLE に付いてくる E-Ink シールドを接続した状態で
プロンプトに "i2c" と入力します。
するとプロンプトは "CM0P:i2c>" にかわります。
更に "scan" と入力すると I2C バス上にあるデバイスを探し始め... 0x68 にデバイスがあることが分かります、
これは E-Ink シールドに乗っている BMI160 センサーです。
このセンサはレジスタアドレス 0 を読むと ID を返すことになっています。
そこで "readreg 0" と入力すると、予定通り ID の D1 が返されました。
Now let's try the catch of the day!
Either push "reset" key or Enter "return" to return to the "CM0P:>" prompt.
Then enter "cm4" to switch the core to the CorTex-M4.
The splash says that it is "MCU Tester (CM4)..." and the last command is now "cm0".
Here we can use all commands in the previous mode, except "cm4".
For example, if you enter "i2c" same set of commands are available.
それでは今回の目玉を実験しましょう!
基板の RST ボタンを押すか、"return" コマンドを入力して "CM0P:>" プロンプトに戻ってください。
そこで "cm4" と入力すると、使用コアが CorTex-M4 に変わります。
オープニングメッセージも "MCU Tester (CM4) ..." となってコマンドリストの最後は cm0 に変わっています。
ここで cm0 の時に使えたコマンドは cm4 を除き全て同様に使用できます。
例えば ”i2c" と入力すると I2C モードで使用できた全てのコマンドがここでも使えます。
To return the root prompt, enter "return".
Then enter "mem" to test the Memory Mode.
According to the TRM of PSoC 6/62 SRAM seems to be starting from 0x08000000.
So please enter "dump 0x08000000" to see what in the memory now.
トップレベルのプロンプトに戻るには、"return" を入力します。
次にメモリーモードを試したいので、"mem" と入力してください。
PSoC 6/62 の TRM によると、SRAM は 0x08000000 から始まっているようなので
"dump 0x08000000" と入力して、今、メモリーの中に何が入っているのか見てください。
Enter "return" to go back to the root prompt.
Then enter "cm0" to switch the core to CorTex-M0+.
Now we are home.
再度、トップレベルのプロンプトに戻るのに "return" と入力してください。
その後、"cm0" と入力すると CorTex-M0+ のコアに戻ることができます。
ただいま!
To explain all the commands will take some time and energy, so let me cheat by saying that...
For other commands, please refer to the page of the previous version below.
コマンド全ての説明はかなり長くなってしまいますので、各コマンドについては
先のヴァージョンの説明がある以下の URL をご参照ください。
MCU Tester, a Swiss Army Knife for PSoC (CY8CKIT-044 version)
moto
27-May-2020 First introduction lines were added
28-May-2020 Sensor name corrected to BMI160
28-May-2020 There were source/header for spi and i2c missing with the first attachment. Attached file was replace with 200528A version.
2-Feb-2021 A version for CY8CKIT-062-WiFi-BT was added.
15-Feb-2021 A version for CY8CPROTO-063-BLE was added.
Show Less