Search Notebooks
メモ&Tips

tips

Page owner: user Suga koubou

Created 11 Sep 2010.
Last updated 20 Feb 2012

メモ&Tips

Page last updated 20 Feb 2012, by   user Suga koubou   tag tips | 0 replies  

メモ&Tips

Ethernet の MTU (Maximum Transmission Unit)

古いmbedのドライバーは約700バイトまでしかサポートしていなかった。

v29より1500バイトをサポートする。

ソフトリセット

Code

extern "C" void mbed_reset();

mbed_reset();

Code

NVIC_SystemReset();

シリアルターミナルからはbreakを送る([Alt]+[B])

mbed を作る

Eagle CAD のデータなどが公開されている。
USBインターフェースの部分はないが、LPC Xpresso等からJTAG書き込みをすれば同じように使える。

LANのリンクLED

EthernetのPHYチップから出力されているリンクとリンク速度のLED用端子は、LPC1768の P1_25 P1_26 にそれぞれ接続されている。

Code

    DigitalIn link(P1_25);
    DigitalIn speed(P1_26);

EthernetNetIf の動的初期化

Code

    EthernetNetIf *eth;

    eth = new EthernetNetIf;
      or
    eth = new EthernetNetIf(ipaddr, netmask, gateway, nameserver);

    eth->setup();

割込みの禁止・許可

Code

    __disable_irq();

    __enable_irq();

書きこんだファイルはどれが有効?

ファイルのタイムスタンプが最新の .bin ファイルが実行される。
最後に書き込んだファイルか、またはタイムスタンプを更新すればいい。(UNIX or Macなら touch コマンド)

BSD上でも使えるか

BSDでもmountできます。

エンディアン

リトルエンディアンか、ビッグエンディアンか確認した。

Code

// http://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%B3%E3%83%87%E3%82%A3%E3%82%A2%E3%83%B3

#include "mbed.h"

union tag_uEndian {
    int in;            /* 4Byte    */
    unsigned short sh[2];    /* 2Byte×2    */
    unsigned char ch[4];    /* 1Byte×4    */
};

int main() {
    union tag_uEndian En;

    En.in = 0x12345678;
    printf("INPUT is 0x%x\n",En.in);
    printf("short is 0x%x, 0x%x\n",En.sh[0],En.sh[1]);
    printf(" char is 0x%x, 0x%x, 0x%x, 0x%x\n",En.ch[0],En.ch[1],En.ch[2],En.ch[3]);

    return 0;
}

結果、リトルエンディアンだった。

INPUT is 0x12345678
short is 0x5678, 0x1234
char is 0x78, 0x56, 0x34, 0x12

コンパイルエラー、その原因と対策は?

ARMの「RVCT 3.1 Build Tools - Errors and Warnings」に、エラーやワーニングに対する解決指南が書かれている。

USBシリアルは?

CGIやPHPへのHTTP POST

デフォルトではPOSTデータが Content-type: text/html になっており、サーバ側でPOSTデータとして扱われない。

application/x-www-form-urlencoded と指定する。

Code

#include "HTTPClient.h"

     :

    HTTPClient http;

    HTTPText data("application/x-www-form-urlencoded");

     :

    data.puts("key=val&key=val...");

     :

    http.post(URI, data, NULL);

     :

バグ?


戻る (back)


Please login to post comments.