Code Examples Forum Discussions
Hello,
This is a sample code for wakeup from DeepSleep using UART for CY8CKIT-145-40XX.
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.
Unfortunately, the data received for wakup is unreliable.
Please see the wake up time TDEEPSLEEP in "PSoC 4 Serial Communication Block (SCB)" datasheet.
for example:
parity:none
send data -> recieved data
0x11 0xf1
0x32 0x99
0x00 0xff
0xff 0xff
parity:even
send data -> recieved data
0xff 0x7f
note:
Since the communication settings of KitProg3 are as follows, it is not possible to send and receive by setting parity.
Best regards,
Yocchi
Show LessHello,
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 Less