LoginSignup
4
8

More than 5 years have passed since last update.

CY8CKIT-059(PSoC5LP)のUSBUARTを使う。

Last updated at Posted at 2015-12-06

この記事はPSoC Creator3.3を使っています。

CY8CKIT-059とは

PSoC5で安価に開発モジュールです。
PSoC、デジタル、アナログ混載モジュールで、通常のマイコンではできない信号の増幅などが出来ます。
秋月電子さんやスイッチサイエンスさんなどで1500円から2000円程度で手に入ります。

UART

このモジュールには、書き込み器経由(KitProg)とマイクロUSB経由の2種類でPCと通信することができます。

kit経由の時のTip

Rx_1をP12[6]、Tx_1をP12[7]と接続します。

KitProgとtargetを分離したときはkitProgとターゲットの接続が必要(TargetRx-KitProgTx, TargetTx-KitProgRx)
KITPROG1.png

main.c
int main()
{
    CyGlobalIntEnable; /* Enable global interrupts. */
    /* Place your initialization/startup code here (e.g. MyInst_Start()) */
    UART_1_Start();
    for(;;)
    {
        /* Place your application code here. */
        UART_1_PutString("test");
        CyDelay(2000);
    }
}

マイクロUSB経由のTip

モジュール(USBUART(CDC Interface))を配置します。

Configuration Descriptor

電源をどうするか指定します。普通はUSBから電源を供給するのでBUSパワーだと思います。電流は、適当に指定してください。
USBUART1.png

Device Descriptor

  • VendorIDは、Cypressのものを使う場合はそのままで
  • ProductIDは、適当につけます。(問題なければそのままが良いと思います。)変わるとドライバーをその都度入れる必要があります。(ドライバー*.infのファイル内は自動で変更してくれるみたいです。)
  • Device Numberはプログラムで必要です。 USBUART2.png

クロックの設定

安価な製品なのでクリスタルは付いていませんが、大丈夫と思います。
USBに48MHzが行くようにします。
USBUART3.png

USBUART4.png

プログラム

USBUART_Startのところですが
USBUART_1_Start(Device, mode)
の引数が要ります。定義を見ると以下のように書かれています。
modeを間違えるとコンピュータに電源が上手く行かないので、USBのエラーや記述子の読み取りエラーなどが出ます。PC側で見ると、VIDが000PIDが002?になる。

  • device: Contains the device number of the desired device descriptor.The device number can be found in the Device Descriptor Tab of "Configure" dialog, under the settings of desired Device Descriptor, in the "Device Number" field.
  • mode: The operating voltage. This determines whether the voltage regulator is enabled for 5V operation or if pass through mode is used for 3.3V peration. Symbolic names and their associated values are given in the following table.

    • USBUART_1_3V_OPERATION : Disable voltage regulator and pass-thru Vcc for pull-up
    • USBUART_1_5V_OPERATION : Enable voltage regulator and use regulator for pull-up
    • USBUART_1_DWR_VDDD_OPERATION : Enable or Disable voltage regulator depend on Vddd Voltage configuration in DWR.
main.c
#include <project.h>

int main()
{
    CyGlobalIntEnable; /* Enable global interrupts. */
    /* Place your initialization/startup code here (e.g. MyInst_Start()) */
    USBUART_1_Start(0, USBUART_1_DWR_VDDD_OPERATION);//
    while(!USBUART_1_bGetConfiguration())  ;
    USBUART_1_CDC_Init();

    for(;;)
    {
        /* Place your application code here. */
        while(USBUART_1_CDCIsReady()==0u);
        USBUART_1_PutString("USB Test\r\n");
        CyDelay(1000);
    }
}

接続時のドライバーが必要ですが、それは、プロジェクトフォルダ\Generated_Source\PSoC5内にUSBUART_1_cdc.infができるので、それを使用しますが、署名が無いので、ベストテクノロジーさんのホームページを参考にしました。
http://www.besttechnology.co.jp/modules/d3blog/details.php?bid=119

4
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
8