MCU Tester, a Swiss Army Knife for PSoC (CY8CKIT-059 version)

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

I 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 版にたどり着きました!

IMG_4271.JPG

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

010-tty.JPG

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] をこちらに割り当てても良いかも知れません。

011-pwm.JPG

adc

012-adc.JPG

i2c

014-i2c.JPG

gpio

015-gpio.JPG

spi

016-spi.JPG

Pins

017-pins.JPG

Tera Term logs

Opening

000-opening.JPG

Mem (Memory)

001-mem.JPG

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” コマンドを使用することで下記のような動作をさせることが可能です。

003-i2c-with-loop.JPG

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 を接続して行いました。

004-adc.JPG

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 を押したり離したりしています。

005-gpio.JPG

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 は動作を開始します。

006-pwm-1.JPG

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" コマンドを送ると下記の画面のような結果になりました。

この機能はオシロスコープで波形を観測することを想定して入れてみました。

入力値の書式が 十進になっている理由は? 失念しました。

将来、入力値の扱いを変えるかもしれませんが、これが現状の設定です。

017-spi.JPG

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)

3 Replies
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

 

I added schematic page enable/disable support.

Except tty, each schematic page can be enabled/disabled before compiling the project.

 

tty 以外の回路図ページを個別にenable / disable 出来るようになりました。

テストしたいコンポーネント以外のページを disable することで、必要なコンポーネントだけのテストが可能になりました。

 

Please refer to the description in the following sample.

使用方法は下記のサンプルページをご参照ください。

 

PSoC Creator Schematic Page Enable/Disable Sample

 

moto

15-Mar-2021 Replaced the attached project with the newer version.

Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked

Hi Moto-san,

Thanks for the effort you have taken in developing the project and sharing it with the community. We appreciate this.

Best Regards,
Vasanth

lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

I introduced a bug when I implemented loop in I2C,

which caused "readreg" command hang.

Attached is the fixed version.

moto

0 Likes