Code Examples Forum Discussions
text.format{('custom.tabs.no.results')}
Hi Team,
I am trying duplex communication between Tera Term and (CY8CKIT-050)PSOC 5LP. I design PSoc Creater as below and written the below c program. Trying to communicate with tera term.
- Let me know whether the attached steps are correct or not?
- Why the serial port radio button is disabled?
I have attached all my design and code.
Thanks,
Abinash
Show LessHi all,
I used the piezoelectric buzzer on PSoC 6 before, so I made a similar one on PSoC 4.
The environment used is as follows:
・PSoC Creator 4.3
・CY8CKIT-062-BLE
The buzzer sounds if you simply set the PWM to the audible range and output it, but I expressed it using another PWM so that it would be beep sound like pi, pi, pi... The image of the output waveform is as follows:
PWM_1 creates the period of sound output, and PWM_2 creates the frequency of the sound. The kill input of PWM_2 is used to control whether or not the sound output. The circuit is as follows:
PSoC 4's TCPWM has a slightly different display of component settings than PSoC 6, but you can do the same thing. The LED pin is output to check the period. The piezoelectric buzzer is connected to Buzzer pin and via 1kΩ to GND. If you want a louder sound, connect it to the output of pwm_n in PWM_2 instead of GND.
PWM_1 creates period of buzzer with 1MHz of Clock_1 as the clock input. PWM_1 is a PWM (check "PMW" in Configuration" tab in the component), and it is divided into 10Hz (100mS) by Prescale=”x2” and Period=49999 in “PWM” tab. The settings are as follows.
PWM_2 is where you set the frequency of the sound. The frequency of the sound is decided by inputting the clock of 1MHz and dividing this. This time, 2KHz (Period=499) and 50% duty (Compare0=250). If you want to change the frequency of the sound, change the Period value here. We recommend a duty of 50%. Otherwise, the sound will be a bit dirty.
In order to control the output of PWM_2, a Start/Stop input is provided, and the edge of the input signal of line coming from PWM_1 is used as a trigger to start and stop with a trigger. The setting of PWM_2 is as follows.
Pin settings are output only. LED is set to P3[6] (green LED) and Buzzer pin is set to P3[0]. The parameter setting of the pin is the same for both, check the Digital output and HW connection, and set the Drive mode to “Strong Drive”. The settings are shown below.
The program in main.c is simple. Since the PWM is only started, the CPU will be released when the setting is completed. The program is below.
#include "project.h"
int main(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
/* Place your initialization/startup code here (e.g. MyInst_Start()) */
PWM_2_Start();
PWM_1_Start();
for(;;)
{
/* Place your application code here. */
}
}
Thanks,
Kenshow
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 を初めて使用する方に基本的なコンポーネントの使い方をお見せするとともに
新しく作った基板や周辺をアプリケーションが出来る前に試せるようにと考えて作ってみました。
So I made versions of this program for PSoC 4 (CY8CKIT-044) and PSoC 6 (CY8CKIT-062-BLE).
MCU Tester, a Swiss Army Knife for PSoC (CY8CKIT-044 version)
MCU Tester, a Swiss Army Knife for PSoC (CY8CKIT-062-BLE version)
And finally, here is the version for PSoC 5LP!
このプログラムの PSoC 4 版と PSoC 6 版を先に公開していましたが
MCU Tester, a Swiss Army Knife for PSoC (CY8CKIT-044 version)
MCU Tester, a Swiss Army Knife for PSoC (CY8CKIT-062-BLE version)
やっと、PSoC 5LP 版にたどり着きました!
Initially I was planning to do PSoC4, PSoC 5LP and PSoC 6, but somehow I could not make the I2C of PSoC 5LP work this time.
So I assumed that my old CY8CKIT-059 is finally broken after all the abuse(s) and ordered a couple of new ones to DigiKey.
And alas, once new one arried, the old one decided that it's time to wake up !?
当初、PSoC 4, PSoC 5LP, そして PSoC 6 版と進めようと考えていたのですが、何故か今回は PSoC 5LP の I2C を動かすの苦労しました。
これは、今までだいぶいじめてきたので、CY8CKIT-059 が逝ったかなと思い DigiKey にお替りをお願いしました。
しかし、例によって新米が届いたとたんに古い方が、こりゃ仕事をしないとまずい!と思ったようで・・・
So the schematic(s)
tty
pwm
Note: Since LED was used for GPIO, I connected an external LED to P2[0] to test PWM.
May be you can change the pin to P2[1] to utilize the on board LED.
注: 基板上の LED は GPIO に割り当ててしまったので、外付けの LED でテストをしました。
基板上の LED を使用するのであれば、P2[1] をこちらに割り当てても良いかも知れません。
adc
i2c
gpio
spi
Pins
Tera Term logs
Opening
Mem (Memory)
i2c
"scan" command scans devices on the bus.
Here it found a device at 0x48, which was LM75B.
So I set the slave address to 0x48 using command "slave 0x48"
Unconditional reading a byte is "read", although I entered "read 0", 0 was igonared.
Register read is "readreg <reg address>"
Multiple registers read is "readregs <starting reg address> <number of registers to read>"
Since there is/are some sensor/devices which require some delay after receiving the address
and before preparing the data to be read, "delay" commands set delay in ms between them.
For devices such as temperature sensor and acceleration sensor etc,
utilizing "loop" and "interval" command will be used as below.
"scan" コマンドはバス上のデバイスをスキャンします。
ここでは接続してあった LM75B を見つけています。
“slave 0x48” コマンドでスレーブアドレスを 0x48 (LM75B) に設定しました。
I2C バスからの無条件読み込みは“read”コマンドで行えます。間違って“read 0” と入力しましたが 0 は無視されていました。
特定のレジスタ読みは“readreg <レジスタアドレス>”
複数レジスタの連続読出しは “readregs <開始レジスタアドレス> <読出しレジスタ数>”
デバイスによってはアドレスを受け取ってからデータを用意するのに時間が必要なものがありますので
“delay” コマンドで ms 単位の遅延を指定できます。
また、温度や加速度センサのように繰り返して同じレジスタを読みたいデバイスの場合には
“loop” と “interval” コマンドを使用することで下記のような動作をさせることが可能です。
adc
"measure" triggers a single shot measurement.
"repeat" triggers a "loop" number of measurements with "interval" ms.
I connected an external POT to test this.
"measure" コマンドで単発の測定を行います。
"repeat" コマンドでは "loop" で設定された回数の測定を"interval" で設定された間隔をあけて行います。
この実験は外部に POT を接続して行いました。
gpio
A digital input is assigned to the SW (P2[2]), and a digital output is assigned to the LED (P2[1]).
"write 1" turns the LED on, "write 0" turns it off.
"read" reads status of both input and output.
In the following example, I pushed and released the SW during the "repeat" loop.
SW (P2[2]) をデジタル入力に、LED (P2[1]) をデジタル出力に設定してあります。
"write 1" とすると LED が点灯し、"write 0" とすると消灯します。
"read" コマンドでは、入力、出力の両方を値を読み込んで表示します。
下記の例では、'repeat" によるループの間に SW を押したり離したりしています。
pwm
I set the PWM clock to 10kHz in the schematic.
So if period is 1000 and compare is 500, we see about 10Hz blinking.
With the period of 10000 and compare of 5000, we see about 1Hz blinking.
Then setting period to 100 and compare to 50 by using "config 100 50",
we get about 100 Hz blinking, which is intensity of the LED to my eyes.
So if I change compare to "0", LED turns of, then changing this value to 10, 50, 100,
the intensity gets brighter and brighter.
"stop" stops the PWM and the LED turns off.
"start" starts the PWM again.
回路図で PWM のクロックを 10kHz に設定しました。
周期を 1000 比較値を 500 に設定すると 10 Hz 程度の点滅になります。
周期を 10000 比較値を 5000 にすると 1Hz 程度の点滅となります。
また、"config 100 50" コマンドを使用して周期 100 比較値 50 とすると
だいたい 100 Hz の点滅になり、私の目には点灯が続いているようにしか見えなくなります。
ここで比較値を 0 にすると消灯になり、10, 50, 100 と上げていくと
徐々に明るさが増すように見えます。
"stop" コマンドは PWM を停止しますので、周期、比較値に関わらず LED は消灯します。
"start" コマンドで PWM は動作を開始します。
spi
At first I connected MISO to GND, "write 22" command read "0x00 (0)"
Then I connected MISO to VDD, "write 22" command read "0xFF (255)"
Finally I connected MISO to MOSI, "write 22" command read "0x16 (22)"
Then I set loop = 5, interval = 100, and "repeat 32" commands show the result below.
I expected to use this function to view the waveform with an oscilloscope.
Why the input value is in decimal format? Sorry I don't remember.
Maybe, in the future version I will change it but for the time being, it is as it is.
最初に MISO を GND に接続して、"write 22" コマンドを送ると RX は "0x00 (0)" でした。
次に MISO を VDD に接続して、"write 22" コマンドを送ると RX は "0xFF (255)" でした。
最後に MISO を MOSI に接続して、"write 22" コマンドを送ると RX は "0x16 (22)" でした。
loop = 5, interval = 100 の設定で、"repeat 32" コマンドを送ると下記の画面のような結果になりました。
この機能はオシロスコープで波形を観測することを想定して入れてみました。
入力値の書式が 十進になっている理由は? 失念しました。
将来、入力値の扱いを変えるかもしれませんが、これが現状の設定です。
27-May-2020
moto
P.S. On 16-Jul-2020 A bug found in I2C / readreg command, attached version is the fixed on (mcu_tester_059_200716)
Show LessHi,
Provided is a custom component, Sync32 v0.0, which can synchronize 1 to 32 digital signals to the rising edge of the clock. It can directly substitute standard Sync component while occupying much smaller footprint on the schematic. Component can can be applied to a single line, multiple lines or bus. Component can use internal clock (BUS_CLK or HFCLK), eliminating the need for external clock. Component is compatible with PSoC4 and PSoC5.
Attached archive contains the component library, a Datasheet and installation instructions. Upon installation it will show up in the folder /Community/Digital/Utilities/Sync/
The component provided as-is, no liabilities. It is free to use, modify and distribute.
/odissey1
Figure 1. Size comparison of the components: Left - standard Sync, Right - custom Sync32.
Typical application ideas of the Sync32 component:
Figure 2. Left - original schematic using standard Sync, Right - schematic modified using Sync32.
Figure 2. Left - original schematic using standard Sync, Right - schematic modified using Sync32.
Show Less
To all,
I've attached a project targeted at exploring how to adjust the PSoC5 IMO and ILO clocks by modifying the trim value at run-time. The original goal with to provide a replacement for the Cypress component ILO_trim and the now depreciated (retired) IMO_trim.
It was intended to be a learning exercise and boy it WAS! Adjusting the IMO clock more than just a few trim values can result in CPU misclocking and UART baudrate clock errors without the proper precautions. This exercise helped me to appreciate all the care Cypress put in defining the clock control registers.
The project allows the user to select the base internal IMO frequency and it allows the user to adjust the IMO clocks in real-time from 1MHz to 80MHz.
The project will also allow the user to trim the ILO clock to a "more" accurate 1KHz.
Build Requirements:
- This project was targeted for the inexpensive CY8CKIT-059 board. It is possible that these projects can be converted to run on other boards that build under PSoC Creator.
- To successfully run this project, you must solder a standard low-cost watch crystal across pins P15[2] and P15[3]. This is the accuracy reference fot he internal RC IMO and ILO clocks.
- PsoC Creator 4.2 or higher.
- To access the needed String_Funcs Component and MenuCmds Component for the build. Refer to this link to access these component libraries: Terminal Support Component Library
I hope this aids in your understanding of the low-level control of the IMO and ILO clocks and the related subsystems.
Len
Show LessHello,
This is a sample project that prepares 300 bytes of UART software buffer and controls RTS-CTS.
If you press SW2, the data sent from TX of UART is looped back by RX, and the data is sent to the terminal software of PC by Software Transmit UART.
The configuration of RTS-CTS is as follows.
The configuration of both circular software buffer TX and RX are as follows.
You must wire RTS to CTS and TX to RX with external wiring.
Make sure to pull up via the resistors on CTS and RX.
If you press SW2, you will receive a message.
Best regards,
Yocchi
Show LessI've attached a custom component that is a TopDesign selectable component for the PSoC5 LPF (low-pass filter) block.
Previously the 2 fixed function LPF blocks available in the PSoC5 were only available by accessing the PSoC5 registers directly. With this component, it can be included, configured (4 corner frequency selections) and routed by PSoC Creator.
This component has a number of run-time APIs to allow for setting a "new" corner frequency and to stop or disable it.
If the component is Stopped or Disabled, the LPF will automatically BYPASS to allow the full frequency spectrum of the input to the output. Re-enabling or starting the LPF will invoke the last corner frequency setting.
Requirements:
- PSoC Creator 4.2 or higher.
- PSoC5 Device Family.
Enjoy,
Len
Show LessHi all,
The electronic dice I posted last time was very popular. So, I add a piezoelectric buzzer to generate sound with PWM. Please refer to the link for details regarding the electronic dice and the piezoelectric buzzer of PWM.
The environment used is as follows:
・PSoC Creator 4.2
・CY8CKIT-062-BLE
The counter of the dice used the timer last time, but I changed it to PWM (PWM_1) because I want to control the length of the sound with Low/High signales. It is PWM_2 that produces the beep sound. PWM_2 used Start and Stop (Kill) inputs to control the blinking of the LED and the duration of the sound. The circuit is as follows:
The period of PWM_1 is set to the same period as the previous timer setting (Period0 = 399: 25Hz). Compare0 is set to 200 as the length of beep.
PWM_2 determines the frequency of the beep. This time, it is set to 2KHz (input clock is 1MHz, Period=499). Compare0 is 200 counts and is fixedly used in the program. The settings are as follows:
In the Advance tab, set Start Input to Rising Edge and Kill Input to Falling Edge to enable Start and Stop (Kill) inputs.
The buzzer pin is set to P12 [0] and the other pins are set as follows:
The program contains the control of PWM_1and 2.
#include "project.h"
uint32_t sw=0; //sw is off (Stop rolling dicce)
int main(void)
{
__enable_irq(); /* Enable global interrupts. */
/* Place your initialization/startup code here (e.g. MyInst_Start()) */
Clock_Enable() ;
CapSense_Start();
CapSense_ScanAllWidgets(); // Start Initial Scan
for(;;)
{
if(!CapSense_IsBusy())
{
CapSense_ProcessAllWidgets();
if(sw==0){ // If sw is on, check start botton0.
if(CapSense_IsWidgetActive(CapSense_BUTTON0_WDGT_ID)) // Check button 0 state
{
/* Start rolling dice*/
PWM_1_SetCounter(0);
PWM_1_SetPeriod0(399);
//PWM_1_SetCompare0(200);
PWM_1_Start(); // Start rolling dice
PWM_2_Start();
sw=1; // sw is on
}
}
if(sw==1){ // If sw is on, check stop botton0.
if(CapSense_IsWidgetActive(CapSense_BUTTON1_WDGT_ID)) // Check button 1 state
{
/* Roll dice slowly */
PWM_1_SetCounter(0);
PWM_1_SetPeriod0(1999);
//PWM_1_SetCompare0(200);
CyDelay(1500); // keep rolling slowly for 1.5sec
PWM_1_Disable();// Stop rolling dice
PWM_2_Disable();
sw=0; // sw is off
}
}
CapSense_UpdateAllBaselines();
CapSense_ScanAllWidgets(); // Start next scan
}
}
}
Thanks,
Kenshow
Show LessHi.
This sample uses CY8CKIT-044.
I created a stopwatch timer using segmented LEDs.
The LED display is based on the sample in "TSoC CY8C4146LQI-S433 基板 7SEG LED サンプル ".
Start and stop of the stopwatch timer are judged by interrupt from SW2 of CY8CKIT-044.
The LED time is updated every 100 msec.
State Machine of the stopwatch timer is as shown in the figure.
#define STANBY_MODE 0 /* initial state 7SEG LED "0000" */
#define COUNT_STOP_MODE 1 /* Count stop */
#define COUNT_UP_MODE 2 /* Count up */
Thanks,
Asanuma
Show LessHi,
This is a demo of the simple FM transmitter using PSoC5 (KIT-059). The project is very simple and uses no software code. AC input from the audio source is amplified (0-4V) and applied to the varactor diode, which controls frequency of the ceramic resonator (4.19 MHz). PSoC5 PLL is set to operate at 75.4MHz, which is 18x harmonic of the XTAL. It appears that PSoC5 internal PLL lock time is quite short (<250us), so that PLL can track the audio frequency (up to ~5kHz), though it less efficient at high range. Antenna is made from a 2" piece of wire, which is connected directly to the BUS_CLOCK output. There is no tank circuit, so transmitter emits on many harmonics of the main (1x, 3x, 5x...). Fortunately, 75MHz and 226MHz regions are empty, and emitted power is rather low (<100nW) so there is no issues with FCC.
Any other ceramic resonator will work, the 4.19MHz is what i had at hands. PLL will lock to any XTAL with frequency >=4MHz. The varactor is also not specific, look for any which adjusts in 10-100pf in 0-4V range (hyperabrupt type). Since PLL feedback decreases with modulation frequency, adding simple CR high-pass filter at audio input with Fcutoff~1-4kHz improves FM output.
RTL-SDR receiver dongle was used to receive the signal, and SDR# for visualization. See official website for details:
Project archive is attached.
Project uses the Annotation Library for connection diagram: Annotation library for CY8CKIT-059 Prototyping Kit
YouTube video of transmitter action: PSoC5 FM audio transmitter (PSoC, PSoC5LP, PSoC 5) - YouTube
/odissey1
Figure 1. KIT-059 connection diagram using Annotation Library for CY8KIT-059.
Figure 2. Breadboard assembly (standard bredboard is split in two pieces).
Figure 3. RF receiver: RTL-SDR with short wire as an antenna.
Figure 4. RTL-SDR GUI (SDR#) snapshot at 75.581MHz.
Show Less