Code Examples Forum Discussions
Recently I posted a sample using CY8CKIT-044 but PSoC 4100S seems to be another popular candidate now,
I wrote this for TSoC (CY8C4146LQI-S433).
最近、CY8CKIT-044 用にサンプルをポストしましたが、この頃は PSoC 4100S も人気なようですので、
TSoC (CY8C4146LQI-S433) 版も作ってみました。
schematic / 回路図
As usual, top-level schematic is pretty simple, but the real world jumper wiring was a little bit of work...
例によってトップレベルの回路図はとても簡素だったのですが、ジャンパ配線はそれなりに大変でした・・・
Although the result must be trivial, let me put the pictures.
Note: I just purchased a web-camera arm, which is very helpful to take pictures of the boards.
まぁ、結果は言わずもがなですが、写真を載せておきます。
※ Webカメラ用のカメラアームを買ってみました、こういった基板デモの写真を撮るのに便利ですね。
Also, Launching the Tuner / ついでに CapSense Tuner も立ち上げておきます。
Button1 touched, LED 1 lights / ボタン1 に触れて、LED1 が光っています。
Button2 touched, LED2 lights / ボタン2に触れて LED2 が光っています。
Button3 touched, LED3 lights / ボタン3に触れて、LED3 が光っています。
And the following is the main.c. As TSoC has only 1 LED on board, I light it whenever any of the buttons is/are touched.
最後に main.c を載せておきます。TSoC には LED が一つしか搭載されていませんので、どれかのボタンがタッチされているときには、基板上の LED を点灯して、ボタンに合わせて外部の LED (LED1, LED2, LED3) を点灯するようにしています。
main.c
#include "project.h"
#define LED_ON 1u
#define LED_OFF 0u
#define BUTTON1 0x01
#define BUTTON2 0x02
#define BUTTON3 0x04
uint8_t button = 0 ;
int main(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
EZI2C_Start() ; // <----
EZI2C_EzI2CSetBuffer1( // <----
sizeof(CapSense_dsRam), // <----
sizeof(CapSense_dsRam), // <----
(uint8_t *)&(CapSense_dsRam)) ; // <----
CapSense_Start() ;
CapSense_ScanAllWidgets() ;
for(;;) {
if (CapSense_NOT_BUSY == CapSense_IsBusy()) {
button = 0 ;
CapSense_ProcessAllWidgets() ;
CapSense_RunTuner() ; // <------
if (CapSense_IsSensorActive(CapSense_BUTTON0_WDGT_ID, CapSense_BUTTON0_SNS0_ID)) {
button |= BUTTON1 ;
LED1_Write(LED_ON) ;
} else {
LED1_Write(LED_OFF) ;
}
if (CapSense_IsSensorActive(CapSense_BUTTON0_WDGT_ID, CapSense_BUTTON0_SNS1_ID)) {
LED2_Write(LED_ON) ;
button |= BUTTON2 ;
} else {
LED2_Write(LED_OFF) ;
}
if (CapSense_IsSensorActive(CapSense_BUTTON0_WDGT_ID, CapSense_BUTTON0_SNS2_ID)) {
button |= BUTTON3 ;
LED3_Write(LED_ON) ;
} else {
LED3_Write(LED_OFF) ;
}
if (button) {
LED0_Write(LED_ON) ;
} else {
LED0_Write(LED_OFF) ;
}
CapSense_ScanAllWidgets() ;
}
}
}
moto
Show Less
Hi,
I am looking for a simple guide on how to connect a sensor to the BLE module (CY8C4248). not just the programming part, but also how the pins are connected. I prefer a low energy sensor as my final goal is to implement a low power sensor with BLE module and receive its data
Hi,
I am using CYBLE212020-01 when i tried to make use of same port two pins as interrupt I am getting error as "mixed interrupt can not assign", Please some one help me to resolve this.
Attached the image.
Show LessHello,
I am trying to use two I2S instances to design a project for collecting data using im69d130 microphone shield2go from Infineon. As per the datasheet, I can use two I2S block. One is on port5 and other on port 11.
However, to startwith, I am trying to initialise I2S but initialisation fails. I am making use of HAL library.
Should I configure clocks for Shield2Go board, it has three pins: DATA, SCLK,WCLK? Is I2S instance master or slave?
How in general we can read mic data using m69d130 microphone shield2go.
My code looks like this:
1) cyhal_i2s_t i2s_0;
const cyhal_i2s_pins_t i2s_0_rx_pins = { .sck = P5_4, .ws = P5_5, .data =
P5_6 };
const cyhal_i2s_config_t i2s_0_config = { .is_tx_slave = false,
.is_rx_slave = true, .mclk_hz = 0, .channel_length = 16,
.word_length = 16, .sample_rate_hz = 24000u };
cy_rslt_t result = cyhal_i2s_init(&i2s_0, NULL, &i2s_0_rx_pins,
NC, &i2s_0_config, NULL);
The result variable is expected to return 0 if everything goes well. It return me a big integer number that means I2S was not initialised. Can you tell me how to proceed?
2 ) Also, is there a way to see the value of variable with out optimisation? While debugging, I see <optismized value>.
I tried to use volatile keyword like volatile cy_rslt_t result , but I dont want to use it all the time. Is there away to turn off optimisation in debug mode? updating CXXXFlags in project make file does not work.
I used emptyPSoC app to create the project.
Thankyou.
Show Less
最近、私の同僚が CapSense のデモ用に設計してエレファンテック社にオーダーしたフレキのセンサー電極を少し分けてもらうことができました。
https://www.elephantech.co.jp/
Recently one of my colleague gave me a few sensor electrode of flex PCB he designed and ordered to Elephantech.
https://www.elephantech.co.jp/en/
フレキと標準の変換は下記基板を入手して使いました。
I used an adapter from the URL below
https://www.aitendo.com/product/19419
最初、CY8CKIT-043 でも試してみたのですが、EZI2C を使用した CapSense Tuner と
KitProg 経由 UART の相性があまり良くない気がしたので、いつもの CY8CKIT-044 に乗り換えて
以前買ってあった Adafruit の TFT を使用しました。
※ ILI9341/SPI/QVGA タイプの TFT であれば他のものでも使えると思います。
https://learn.adafruit.com/adafruit-2-8-tft-touch-shield-v2
At first I tried with CY8CKIT-043, but I found that EZI2C used for the CapSense Tuner and UART via KitProg do not go well, so I changed the hourse to my trusty CY8CKIT-044 and used the Adafruit TFT, which I purchased before.
Note: Probably any TFT with ILI9341/SPI/QVGA can work, too.
https://learn.adafruit.com/adafruit-2-8-tft-touch-shield-v2
Launching the CapSense Tuner / キャップセンス チューナーを起動します
CapSense Tuner started / キャップセンス チューナーが立ち上がりました
Click "Connect" icon in the top left / 左上にある "Connect" ボタンを押します
接続されるとボタンは "Disconnect" という表示に変わります。
The button changes to "Disconnect" when connection is established.
次に "Start" アイコンを押します。(私はいつもこれを忘れてしまいます。orz)
チューナーの動作が開始されると表示が "Stop" に変わります。
Then click "Start" icon. (Note: I always forget this >_< )
The button changes to "Stop" when the tuner started working.
ボタン1にタッチした状態
When button1 is touched
ボタン2にタッチした状態
When button2 is touched
ボタン3にタッチした状態
When button3 is touched
表示を GraphView タブに変えた時
Switching to the GraphView Tab
評価基板上のキャップセンス電極が機能するのは当然と言えるかも知れませんが、
他の電極を接続しても、殆ど手間いらずでボタンを検知できる SmartSense の機能は
ありがたいものだと思いました。
Although it is natural that EVB's on board electrodes work OK, when connecting other electrode and it works without any tuning nor hustle seems to be a great benefit of the SmartSense functionality.
schematic / トップレベル回路図
CapSense Configuration / キャップセンスの設定
各ボタン電極のチューニング実験をしてみたかったので
本来は一つのウィジェットで3つボタンの設定でも行けるのですが
あえて三つのウィジェットに各ボタンを割り振ってみました。
As I was planning to play with tuning each button electrode,
I assigned each button to different widgets.
It should work with one widget of 3 buttons, though.
Pins / ピン設定
main.c
#include "project.h"
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "TFT.h"
#include "Arial12x12.h"
#include "Arial28x28.h"
#define USE_TUNER 1u
#define STR_BUF_LEN 64
char str[STR_BUF_LEN+1] ;
typedef struct _button {
int value ;
int x ;
int y ;
int w ;
int h ;
} Button_Type ;
#define BUTTON_WIDTH 70
#define BUTTON_HEIGHT 70
Button_Type button[3] = {
{ 0, 30, 70, 70, 70 },
{ 0, 130, 70, 70, 70 },
{ 0, 230, 70, 70, 70 }
} ;
typedef struct I2CRamBuffer
{
uint16 u16_rawdata[CapSense_TOTAL_SENSORS];
uint16 u16_baseline[CapSense_TOTAL_SENSORS];
uint16 u16_signal[CapSense_TOTAL_SENSORS];
uint8 u8_sensorStatus;
} I2CRamBuffer;
void draw_button(Button_Type *button, uint16_t color)
{
TFT_fillrect(button->x, button->y, button->x + button->w, button->y+button->h, color) ;
}
void init_hardware(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
#if USE_TUNER
EZI2C_Start() ;
EZI2C_EzI2CSetBuffer1(
sizeof(CapSense_dsRam),
sizeof(CapSense_dsRam),
(uint8_t *)&(CapSense_dsRam)) ;
#endif
TFT_CS_Write(1) ;
TFT_DC_Write(0) ;
TFT_BL_Write(0) ;
SPI_Init() ;
SPI_Start() ;
TFT_BusEnable(1) ;
TFT_Init() ;
TFT_foreground(White) ;
TFT_background(Black) ;
TFT_BusEnable(1) ;
TFT_cls() ;
TFT_BusEnable(0) ;
TFT_BL_Write(1) ;
CapSense_Start() ;
CapSense_ScanAllWidgets() ;
}
int doCapSense(Button_Type *button)
{
int result = 0 ;
if (CapSense_NOT_BUSY == CapSense_IsBusy()) {
CapSense_ProcessAllWidgets() ;
#if USE_TUNER
CapSense_RunTuner() ;
#endif
if (CapSense_IsWidgetActive(CapSense_BUTTON0_WDGT_ID)) {
button[0].value = CapSense_IsSensorActive(CapSense_BUTTON0_WDGT_ID, CapSense_BUTTON0_SNS0_ID) ;
result = 1 ;
} else {
if (button[0].value != 0) {
button[0].value = 0 ;
result = 1 ;
}
}
if (CapSense_IsWidgetActive(CapSense_BUTTON1_WDGT_ID)) {
button[1].value = CapSense_IsSensorActive(CapSense_BUTTON1_WDGT_ID, CapSense_BUTTON1_SNS0_ID) ;
result = 2 ;
} else {
if (button[1].value != 0) {
button[1].value = 0 ;
result = 2 ;
}
}
if (CapSense_IsWidgetActive(CapSense_BUTTON2_WDGT_ID)) {
button[2].value = CapSense_IsSensorActive(CapSense_BUTTON2_WDGT_ID, CapSense_BUTTON2_SNS0_ID) ;
result = 4 ;
} else {
if (button[2].value != 0) {
button[2].value = 0 ;
result = 4 ;
}
}
}
CapSense_ScanAllWidgets() ;
return( result ) ;
}
int prev_button[3] = { 0, 0, 0} ;
void draw_a_button(Button_Type *button)
{
TFT_BusEnable(1) ;
TFT_set_font(Arial12x12) ;
TFT_locate(button->x + 25, button->y + 30) ;
if (button->value) {
draw_button(button, Yellow) ;
TFT_background(Yellow) ;
TFT_foreground(Black) ;
TFT_putstr("ON ") ;
} else {
draw_button(button, Blue) ;
TFT_background(Blue) ;
TFT_foreground(White) ;
TFT_putstr("OFF") ;
}
CyDelay(10) ;
TFT_BusEnable(0) ;
}
void draw_buttons(Button_Type *button)
{
int i = 0 ;
for (i = 0 ; i < 3 ; i++ ) {
draw_a_button(&button[i]) ;
}
}
int main(void)
{
int i ;
init_hardware() ;
draw_buttons(button) ;
for(;;) {
if (doCapSense(button)) {
for (i = 0 ; i < 3 ; i++ ) {
if (button[i].value != prev_button[i]) {
draw_a_button(&button[i]) ;
prev_button[i] = button[i].value ;
}
}
}
}
}
moto
Show Less
Hi,
Here I submitting my version of the 24-bit DDS arbitrary frequency generator component. It is useful for applications requiring precision frequency generation. Provided below are: component library, datasheet, application note and several demo projects exemplifying use of the component.
Many thanks to authors of various previous incarnations of DDSs: <PSoC73>, <pavloven>, <vdvorak>, <kabron>, <JLS1>.
This component was developed as part of Warp Verilog study and does not pursue any particular purpose.
odissey1
video link: DDS tunable frequency / phase generator using Cypress PSoC5 - YouTube
Show Less
Hello....
Starting with Cypress controller, what development kit or code examples helps me to develop small test application to verify the proper working of UART, SPI, I2C, GPIO, Clocks etc. peripherals.??
I have IAR 8.4 Workbench IDE for programming and debugging code, so looking for example codes in IAR IDE support.
Show LessI've attached a project that has DMA-driven function equivalents for:
- memset() => dmemset()
- memcpy() => dmemcpy()
- memmove() => dmemmove()
It uses a single DMA channel and TD resource for these functions.
The reason for this project is to see how much faster the transfer of data can occur from these replacement functions.
Summary: Transfer sizes 64 bytes or above (@ BUS_CLK = 72 MHz) are faster than the standard string library equivalents.
At a transfer size of 4095 bytes (maximum DMA TD transfer count), the transfer time is over 7 times faster!
This project is written for a PSoC5 but can easily be converted to other PSoC families that have DMA resources.
I welcome any suggestions for improvements.
I'm also considering making this into an installable component. Your thoughts.
Enjoy!
Show Less
Hi,
We have connected psoc 5 usb pins to an arm based board .I want to know if there is any boot tool in Linux which we can use to flash the board.
Regards,
Madhav
Show Less
Hi,
Uploaded below is a demo project showing 16-bit PWM DAC using 8-bit Fractional PWM and 8-bit Delta-Sigma Modulator and simple RC-filter.
The PWM DACs are popular in budget audio applications due to their simplicity. The known issue of this approach is very slow response due to the necessity to filter out the main PWM harmonic: PWM_Clock / 2^N, where N - is the number of PWM bits. For 16-bit PWM, and clock frequency of 48MHz, this results in 48MHz / 2^16 = 732 Hz, which is rather slow for audio use. For 8-bit PWM, the main lobe is located at 48MHz / 2^8 = 187.5 kHz, which is acceptable for audio applications. Unfortunately, 8-bit output amplitude is not nearly enough in most cases. The project below tries to resolve this dilemma by using fast 8-bit Fractional PWM, where output duty cycle is externally switched between the (MSB) and (MSB+1) positions using custom Delta-Sigma Modulator. The PWM provides the MSB (most significant bit), while Delta-Sigma Modulator provides the LSB. This way the PWM can operate at high frequency of 187.5kHz, while the DeltaSigma Modulator provides extra bits of resolution.
As usual with PWM DACs, the absolute accuracy depends on the stability of the driving voltage Vdd, output buffer speed and symmetry against Vdd and Vss (Gnd). Any fluctuations on the power rail directly affect the DAC output. Simple RC filter provides -43dB suppression of the PWM main harmonic. Using (pseudo-) second-order filter, made of two RC filters in series, suppresses it below -75dB.
Attached are two projects: basic and extended. The basic project includes all necessary components, and simply outputs a single voltage. The extended project scans the output from 0-65535, and uses ADC for sampling the DAC values and displaying them using SerialPlot charting software.
/odissey1
Projects include modified 1-st-order Delta-Sigma Modulator, originally developed by FY_ZHU
Extended project also uses additional custom components:
SerialPlot v0.0: Interface to real-time data charts
PSoC Annotation Library v1.0 (optional)
Figure1. Fractional PWM DAC using 8-bit PWM modulated by 1-st order 8-bit DeltaSigma Modulator
Figure 2. PWM output is filtered by simple 1-st order RC filter with R1=2.2k, C1=100nF.
Figure 3. Project annotation using PSoC Annotation Library v1.0. The ADC serves as a voltmeter. The physical connection between Pin 12.7 (UART TX) and the SerialPlot charting software is not required.
Figure 4. SerialPlot output while scanning DAC code 0 to 65500. Blue - DAC code, Red - result measured by ADC, Green - residual (ADC sample - DAC Code). R1=2.2k.
Figure 5. SerialPlot output of the residual (ADC sample - DAC code) for R1=2.2k. Note that the shape of the curve varies with R1 value. The noise is due to the Vdd instability of the USB-powered PSoC prototyping board.
Figure 6. SerialPlot output of the residual (ADC sample - DAC code) for R1=1.0k.
Figure 7. SerialPlot output of the residual (ADC sample - DAC code) for R1=4.7k.
Figure 8. FFT of the AC-coupled DAC output at mid-scale (DAC code = 32767), after single RC filter (R1=2.2k, C1=100nF). The PWM at 187.5 kHz p-p is ~40mV (-43dB). The noise floor is at about -75dB.
Figure 9. FFT of the AC-coupled DAC output at mid-scale (DAC code = 32767), filtered using double serial filter R1C1-R2C2 (R1=2.2k, C1=100nF, R2=2.2k, C2=100nF). The PWM noise at 187.5 kHz is not discernible above the noise floor (-75dB).
Show Less