PSoC CY8C4247LQI-BL483
OUTPUT PINに LED(緑色、赤色、青色)3個の Lチカをしてみました。
Pin_1のProtをP0[0]
Pin_2のProtをP0[1]
Pin_3のProtをP0[2]
制御レジスタを使うと、ファームウェアがデジタル信号を出力できるようになります。
1.プロジェクトの作成
メニューから「File」「New」「Project」を選択
PSoC 4200 BLE Design を選択
Empty schematicを選択
・プロジェクト名
・保存場所
・ワークスペース名
を設定して、「Finish」を押す
2. Digital Output Pin を配置する
右上のComponent
Catalogの検索窓に、「pin」と入力
「Digital Output Pin」を、TopDesign.cysch に3個ドラッグ&ドロップする
Digital Output Pinは、「Pin_1」という名で、生成される。
※写真は、Zoom In で拡大してます。
これをダブルクリックする。
「HW connection」のチェックを入れてOKを押す。
「HW connection」のチェックを入れると接続端子が出ます。
Control Registerを配置します。
Pin_1をControl_Reg_1にドラッグして接続をします。
Pin_1がControl_Reg_1に接続した状態です。
Pin_1,Pin_2,Pin_3をControl_Reg_1に接続します。
Control_Reg_1をダブルクリックします。
Output 8から3に変更します。
Control_Reg_1に3個のPinが表示。
左の Workspace Explorer のDesign01.cydwrを、ダブルクリックする。
Pin_1のProtをP0[0]
Pin_2のProtをP0[1]
Pin_3のProtをP0[2]
に選択
または、「Pin_1」を、ドラッグ&ドロップで、P0[0]につなぐ。
メニューから「Build」「Generate Application」を実行。
(もしくは、Generata Applicationボタンを押す)
これで、現在のハードウェア構成にあわせて、関数群が生成される。
3. コードを書く
左の Workspace Explorer の main.c を、ダブルクリックする。
コードの説明(ざっくり)
Control_Reg_1_Write にそれぞれLED1,LED2,LED3を設定し点灯。
for(;;)文(ループ)で3個のLEDが、ひたすら点灯繰り返す。
#include "project.h"
int main(void)
{
CyGlobalIntEnable; /* Enable global
interrupts. */
/* Place your initialization/startup code here
(e.g. MyInst_Start()) */
uint8 LED1 = 0x01;
uint8 LED2 = 0x02;
uint8 LED3 = 0x04;
for(;;)
{
/* Place your application code
here. */
Control_Reg_1_Write(LED1 | LED2
| LED3 ); // 3個点灯
}
}
/* [] END OF FILE */
メニューから「Debug」「Program」を実行
(もしくは、Programボタンを押す)
設定やコードに間違えがなければ、書き込みデータ生成され、チップに書き込まれ、実行される。
コメントをお書きください
Keva Fennelly (月曜日, 23 1月 2017 13:11)
Hello very cool site!! Guy .. Excellent .. Amazing .. I'll bookmark your website and take the feeds also? I'm glad to seek out a lot of useful information right here within the post, we want develop extra strategies on this regard, thanks for sharing. . . . . .
Elaina Schuch (火曜日, 31 1月 2017 23:31)
I simply could not go away your web site prior to suggesting that I actually enjoyed the usual info an individual supply on your guests? Is gonna be back continuously in order to inspect new posts