GR-PEACH_producer_meeting


Team for GR-PEACH Producer Meeting

You are viewing an older revision! See the latest version

GettingStarted

How to Update the firmware about CMSIS-DAP

Preparation
Download firmware from this URI and extract zipped file.

  • grpeach_8mb_20141209.bin
    • When downloading program of GR-PEACH, block erase command is used instead of chip erase command.
    • It does not need to reconnect USB cable between PC and GR-PEACH before RZ/A1H's program updating.
    • USB serial communication is not work well when Reset button is pushed after updating the RZ/A1H's program.
      • After you change the RZ/A1H's program, restart your terminal software.
  • Old versions
    • grpeach_8mb_20141127.bin
      • Limitation: USB serial communication is not work well when Reset button is pushed after updating the RZ/A1H's program.
      • This firmware is written in current GR-PEACH.
    • grpeach_8mb_20141112.bin
      • Limitation: It needs to reconnect USB cable between PC and GR-PEACH before RZ/A1H's program updating.
  1. Connect GR-PEACH and PC
    Close the JP2 and connect USB cable when you proceed to update the firmware. Step1
  2. After the connection, PC will mount GR-PEACH as mass storage drive that name is 「CRP DISABLED」.
    If PC will mount GR-PEACH as "mbed", you failed JP2 close.
    In this case, re-try previous item.
    When GR-PEACH connected as "CRP DISABLED", it can open the JP2 during firmware updating.
  3. Open the folder and delete the Firmware.bin.
    Step2
  4. Copy the downloaded file to this drive.
  5. When copy is finished, disconnect between GR-PEACH and PC.
  6. Reconnect GR-PEACH and PC.
  7. If you find mass storage drive that volume name is "mbed", firmware update is finished.


Install the USB serial communication driver

For Windows(R) user:

  1. Connect GR-PEACH and PC.
  2. After the mount GR-PEACH as "MBED" volume label, install this driver.


Add compiler for GR-PEACH

  1. The root folder of GR-PEACH mass storage drive includes "mbed.htm" .
  2. This file jumps to the site of GR-PEACH when double clicked.
  3. You can use mbed compiler for GR-PEACH after click at "Add to your compiler" button.
    /media/uploads/ShinjiYamano/jpn_gettingstarted010.png


Let's blink LED

  1. Then launch the development environment from Compiler button.
  2. Select the mbed_blinky from "Import" button. /media/uploads/ShinjiYamano/jpn_gettingstarted011.png
  3. Get the source code to click "Import" button.
  4. Create binary file to click the "Compile" button. /media/uploads/ShinjiYamano/jpn_gettingstarted012.png
  5. When compile is finished, binary file is downloaded using browser function.
    Copy this file to mbed drive.
    For Window user: drag and drop.
    For Mac user : Refer here
  6. When GR-PEACH's reset button is pushed or reconnect USB cable, the program runs.

LEDを滑らかに光らせよう

  1. LEDをチカチカさせようのmain.cppを以下のように書き換え、コンパイルし、実行します。

LED PWM

#include "mbed.h"

PwmOut led(LED_RED);

int main() {
    float crt = 1.0, delta = 0.04;

    led.period_ms(2); // 500Hz
    while (true) {
        led.write(crt);
        wait_ms(50);
        crt = crt + delta;
        if (crt > 1.0) {
            crt = 1.0;
            delta = -delta;
        }
        else if (crt < 0) {
            crt = 0;
            delta = -delta;
        }
    }
}


A/Dコンバータを使おう

  1. LEDをチカチカさせようのmain.cppを以下を参考に書き換え、コンパイルし、実行します。

Arduino A0,A1のA/D変換

#include "mbed.h"

DigitalOut myled(LED1);
AnalogIn   ain0(A0);
AnalogIn   ain1(A1);

int main() {
    myled = 1;
    while(1) {
        myled = !myled;
        printf("ain0 = %8.3f, ain1 = %8.3f\n", ain0.read(), ain1.read());
        wait(1);
    }
}


SPIを使おう

  1. LEDをチカチカさせようのmain.cppを以下を参考に書き換え、コンパイルし、実行します。

Arduino D10-D13を用いたSPI通信

#include "mbed.h"
SPI spi(D11, D12, D13);   // mosi, miso, sclk
DigitalOut cs(D10);

int main() {
    int data = 0;
    int res = 0;

    for(int i = 0; i < 30; i++) {

        cs = 0;
        res = spi.write(data++);
        cs = 1;

        wait_ms(0.001);
    }
}


I2Cを使おう

  1. LEDをチカチカさせようのmain.cppを以下を参考に書き換えます。
  2. コンパイルし、実行します。

Arduino SDA,SCLを用いたI2C通信

#include "mbed.h"

#define SIZE (10)
#define ADDR (0x90)

I2C i2c(I2C_SDA, I2C_SCL);

int main() {
    char buf[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
    char res[SIZE];

    i2c.write(ADDR, buf, SIZE);
    i2c.read(ADDR, res, SIZE);
}


micro-SDを使おう

  1. LEDをチカチカさせようのmain.cppを以下を参考に書き換えます。
  2. プロジェクトのルートディレクトリを選択し、SDファイルシステムの右側の「Import this library」をクリックします。
  3. 途中でダイアログが表示されますので、決して「Update all libraries to the latest version」にチェックを「入れないで」ください。
  4. コンパイルし、実行します。

SPI通信を用いたmicroSD制御

#include "mbed.h"
#include "SDFileSystem.h"

SDFileSystem sd(P8_5, P8_6, P8_3, P8_4, "sd");

namespace {
const char *sd_file_path = "/sd/out.txt";
const int DATA_SIZE = 256;
}

int main()
{
    uint8_t data_written[DATA_SIZE] = { 0 };
    bool result = true;

    // Fill data_written buffer with random data
    // Write these data into the file
    {
        FILE *f = fopen(sd_file_path, "w");

        printf("SD: Writing ... ");
        for (int i = 0; i < DATA_SIZE; i++) {
            data_written[i] = rand() % 0XFF;
            fprintf(f, "%c", data_written[i]);
        }

        printf("[OK]\r\n");
        fclose(f);
    }

    // Read back the data from the file and store them in data_read
    {
        FILE *f = fopen(sd_file_path, "r");
        printf("SD: Reading data ... ");
        for (int i = 0; i < DATA_SIZE; i++) {
            uint8_t data = fgetc(f);
            if (data != data_written[i]) {
                result = false;
                break;
            }
        }
        printf("[%s]\r\n", result ? "OK" : "FAIL");
        fclose(f);
    }
}


イーサネットを使おう

  1. LEDをチカチカさせようのmain.cppを以下を参考に書き換えます。

ehterのサンプルコード

#include "mbed.h"
#include "EthernetInterface.h"
 
struct s_ip_address
{
    int ip_1;
    int ip_2;
    int ip_3;
    int ip_4;
};
 
int main() {
    char buffer[256] = {0};
    s_ip_address ip_addr = {0, 0, 0, 0};
    int port = 0;
 
    printf("TCPCllient waiting for server IP and port...\r\n");
 
    EthernetInterface eth;
    eth.init("192.168.100.2", "255.255.255.0", "192.167.101.3");
    eth.connect();
 
    printf("TCPClient IP Address is %s\r\n", eth.getIPAddress());
    sprintf(buffer, "%d.%d.%d.%d", ip_addr.ip_1, ip_addr.ip_2, ip_addr.ip_3, ip_addr.ip_4);
 
    TCPSocketConnection socket;
    while (socket.connect(buffer, port) < 0) {
        printf("TCPCllient unable to connect to %s:%d\r\n", buffer, port);
        wait(1);
    }
 
    while ( true ) {
        wait(1);
    }
 
    socket.close();
    eth.disconnect();
    return 0;
}

// set mac address
void mbed_mac_address(char *mac) {
    mac[0] = 0x00;
    mac[1] = 0x02;
    mac[2] = 0xF7;
    mac[3] = 0xF0;
    mac[4] = 0x00;
    mac[5] = 0x00;
}

  1. Importボタンをクリックします。
  2. libraryタグから「mbed-rtos」と「EthernetInterface」を選択し、「Import!」をクリックします。 /media/uploads/RyoheiHagimoto/ether_import_libs.png
  3. 途中でダイアログが表示されますので、必ず「Update all libraries to the latest version」にチェックを入れてください。
  4. コンパイルします。
  5. GR-PEACHにプログラムをダウンロードします。
  6. PCのIPアドレスを192.168.100.100に設定します。
  7. GR-PEACHとPCをLANケーブルで接続します。
  8. GR-PEACHをリセットします。
    シリアルで以下が出力されます。
TCPCllient waiting for server IP and port...
TCPClient IP Address is 192.168.100.2
  1. PCからGR-PEACHに向け、PINGを発行します。
PING 192.168.100.2



All wikipages