LPCマイコンのSPIについて

ユーザマニュアルには下記のようにあるが、受信オーバラン分のデータは上書きされないもよう。

ARM の仕様
では、これが発生した場合、前回のフレームデータが新しいフレーム
データによって上書きされます。
UM_LPC111x_UM_Rev.00.15_Japanese P.183

SPI通信では戻りのデータがいらない場合が多々あるので、逐一読みだしていては速度が非常に遅くなる。なので戻りが不要な時は単に送信に徹し、戻りが必要になる送信の直前に受信バッファを空にするするのがベスト。

また、inlineやfor,ifでも残念ながら遅延原因になるようなのでマクロなどでなるべく一括で送信されるように記述するのがベター。

さらなる高速化のためには16bit送信で2バイト分をまとめて送る方法など考えられるがかなり煩雑な実装になると思われる。

Posted in NXP, メモ | Leave a comment

node.js で同期的read

var fs = require('fs');

var fd = fs.openSync("test.txt", "r"); // test.txt = abcdefghij

var buffer = new Buffer(4096);

var len = fs.readSync(fd, buffer, 0, 5, null);

console.log(len, buffer.toString("ascii", 0, len)); // 5 abcde

fs.closeSync(fd);
Posted in node.js | Leave a comment

Windowsでポートフォワード

plink -ssh -2 -P [SSHサーバのポート番号] -l [ユーザ名] -pw [パスワード] -N -L [ローカルで待ち受けるポート]:[リモートにからフォワードしたいアドレス]:[〃ポート] -R [SSHサーバ側で待ち受けるポート]:[リモートにフォワードしたいアドレス]:[〃ポート] [SSHサーバアドレス]

-L -Rの部分は複数個書ける。

またSSHサーバ側のsshd_configを以下のようにしておくと良い。

GatewayPorts yes #フォワードされたポートに他ホストもアクセスできる
ClientAliveInterval 15 # 15秒置きに接続確認する
ClientAliveCountMax 3  # 3度接続が確認できなければ切断する

plinkをラップしたsshコマンドなどもあるようだが、ポートの複数個設定がうまくいかなかった。

Putty: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

Posted in 未分類 | Leave a comment

MCP2515

  • RESETはフローティングだとLow判定になる(つまり常にリセット状態になる)。RESETはプルアップしておく。(100KΩ程度でよい)
  • CLKOUTはデフォルトで有効なので、動作確認に使うとよい。デフォルトで8分周されたクロックが出力される。
Posted in MCP2515, メモ | Leave a comment

FTDI D2XXプログラミングメモ

  • 子プロセスを作るとデバイスにアクセスできなくなるもよう。FT_*関数は親プロセスもしくは一プロセスかつマルチスレッドで統一する。
  • FT_Readにおいて、dwBytesToRead引数が受信可能なバイト数より多い場合、ブロックされる。
  • FT_Readを実行してから初めてモジュールも受信を開始するので別スレッドで待機させておくのがよい。
  • 結局はユーザランドでの実行のようなのでftdi_sioの方が早いもよう。
Posted in FTDI, メモ | Leave a comment

VirtualBoxメモ (ゲスト:Ubuntu12.0.4)

  • 参加しているネットワークが問題なければ、ネットワークをブリッジアダプターにするのが一番問題ないだろう。
  • windowsからubuntuへの名前解決→sambaを入れる。apt-get install samba
  • ubuntuからwindowsへの名前解決→winbindを入れる。 apt-get install winbind
    /etc/nsswitch.confのhostsにwinsを追加する。

ゲストOSへのSSH接続

  • ホストOSからゲストOSに楽にSSH接続したい場合、VirtualBoxの環境設定に以下の通り、VirtualBox Host-Only Ethernet Adapterがあることを確認する。(なければ追加)
  • ゲストのネットワーク設定にアダプタを追加する。割り当ては「ホストオンリーアダプター」にする。(ゲストが起動していると追加できないので注意。)
  •  ゲストOSを起動すると新しくethが認識される。この時点で追加されたethのIPに対してホストOSから通信が可能となる。
  • Ubuntuの場合、sambaを追加するとホスト名で名前解決できるようになる。
    (sudo apt-get install -y sambaで追加)
  • Ubuntuにはssh-serverがデフォルトで入ってないので入れる。
    sudo apt-get install -y ssh
  • 以上。

画面サイズを可変にする

  • ゲストOSが起動した状態で「デバイス」→「Guest AdditionsのCDイメージを挿入」を実行。
    自動実行 の許可が求められるので許可する。
  • 完了後、再起動すれば適用される。
Posted in VirtualBox | Leave a comment

Smarty メモ

  • ロジック側のdefault_modifiersを修正した場合、テンプレートのキャッシュが残っていると反映されないので注意。
Posted in 未分類 | Tagged | Leave a comment

LPC-Link2 メモ

JP2をクローズしないと動かない。以下のエラーが発生。
(ターゲットに完全に切り離して電源は別にした状態でも!)

Error in final launch sequence
Failed to execute MI command:
-target-select extended-remote | crt_emu_cm_redlink -msg-port=52738 -g -mi -2 -pLPC1769 -vendor=NXP -reset= -ProbeHandle=1 -CoreIndex=0 -flash-driver=LPC175x_6x_512.cfx
Error message from debugger back end:
Remote communication error. Target disconnected.: No error.
Remote communication error. Target disconnected.: No error.

詳細は未調査。JP2をクローズにすれば動くのでとりあえずよしとする。

Posted in LPC-Link2 | Leave a comment

descriptor_parser

  • FT232
Start
Device addressed... Requesting device descriptor.
Device descriptor: 

Descriptor Length:	12
USB version:		2.0
Class:			00 Use class information in the Interface Descriptor
Subclass:		00
Protocol:		00
Max.packet size:	08
Vendor  ID:		0403
Product ID:		6001
Revision ID:		0600
Mfg.string index:	01 Length: 10 Contents: FTDI
Prod.string index:	02 Length: 32 Contents: FT232R USB UART
Serial number index:	03 Length: 18 Contents: A50177H2
Number of conf.:	01

Configuration number 0
Total configuration length: 32 bytes

Configuration descriptor:
Total length:		0020
Number of interfaces:	01
Configuration value:	01
Configuration string:	00
Attributes:		A0 Remote Wakeup
Max.power:		2D 90ma

Interface descriptor:
Interface number:	00
Alternate setting:	00
Endpoints:		02
Class:			FF Vendor Specific
Subclass:		FF
Protocol:		FF
Interface string:	02 Length: 32 Contents: FT232R USB UART

Endpoint descriptor:
Endpoint address:	01 Direction: IN
Attributes:		02 Transfer type: Bulk
Max.packet size:	0040
Polling interval:	00 0 ms

Endpoint descriptor:
Endpoint address:	02 Direction: OUT
Attributes:		02 Transfer type: Bulk
Max.packet size:	0040
Polling interval:	00 0 ms
  • MC8795V
Start
Device addressed... Requesting device descriptor.
Device descriptor: 

Descriptor Length:	12
USB version:		2.0
Class:			00 Use class information in the Interface Descriptor
Subclass:		00
Protocol:		00
Max.packet size:	40
Vendor  ID:		1199
Product ID:		683C
Revision ID:		0006
Mfg.string index:	03 Length: 60 Contents: Sierra Wireless, Incorporated
Prod.string index:	02 Length: 16 Contents: MC8795V
Serial number index:	00
Number of conf.:	01

Configuration number 0
Total configuration length: 198 bytes

Configuration descriptor:
Total length:		00C6
Number of interfaces:	07
Configuration value:	01
Configuration string:	01 Length: 42 Contents: Sierra Configuration
Attributes:		E0 Self-powered Remote Wakeup
Max.power:		00 0ma

Interface descriptor:
Interface number:	00
Alternate setting:	00
Endpoints:		02
Class:			FF Vendor Specific
Subclass:		FF
Protocol:		FF
Interface string:	00

Endpoint descriptor:
Endpoint address:	01 Direction: IN
Attributes:		02 Transfer type: Bulk
Max.packet size:	0040
Polling interval:	20 32 ms

Endpoint descriptor:
Endpoint address:	01 Direction: OUT
Attributes:		02 Transfer type: Bulk
Max.packet size:	0040
Polling interval:	20 32 ms

Interface descriptor:
Interface number:	01
Alternate setting:	00
Endpoints:		02
Class:			FF Vendor Specific
Subclass:		FF
Protocol:		FF
Interface string:	00

Endpoint descriptor:
Endpoint address:	02 Direction: IN
Attributes:		02 Transfer type: Bulk
Max.packet size:	0040
Polling interval:	20 32 ms

Endpoint descriptor:
Endpoint address:	02 Direction: OUT
Attributes:		02 Transfer type: Bulk
Max.packet size:	0040
Polling interval:	20 32 ms

Interface descriptor:
Interface number:	02
Alternate setting:	00
Endpoints:		02
Class:			FF Vendor Specific
Subclass:		FF
Protocol:		FF
Interface string:	00

Endpoint descriptor:
Endpoint address:	03 Direction: IN
Attributes:		02 Transfer type: Bulk
Max.packet size:	0040
Polling interval:	20 32 ms

Endpoint descriptor:
Endpoint address:	03 Direction: OUT
Attributes:		02 Transfer type: Bulk
Max.packet size:	0040
Polling interval:	20 32 ms

Interface descriptor:
Interface number:	03
Alternate setting:	00
Endpoints:		03
Class:			FF Vendor Specific
Subclass:		FF
Protocol:		FF
Interface string:	00

Endpoint descriptor:
Endpoint address:	04 Direction: IN
Attributes:		03 Transfer type: Interrupt
Max.packet size:	0040
Polling interval:	05 5 ms

Endpoint descriptor:
Endpoint address:	05 Direction: IN
Attributes:		02 Transfer type: Bulk
Max.packet size:	0040
Polling interval:	20 32 ms

Endpoint descriptor:
Endpoint address:	04 Direction: OUT
Attributes:		02 Transfer type: Bulk
Max.packet size:	0040
Polling interval:	20 32 ms

Interface descriptor:
Interface number:	04
Alternate setting:	00
Endpoints:		03
Class:			FF Vendor Specific
Subclass:		FF
Protocol:		FF
Interface string:	00

Endpoint descriptor:
Endpoint address:	06 Direction: IN
Attributes:		03 Transfer type: Interrupt
Max.packet size:	0040
Polling interval:	05 5 ms

Endpoint descriptor:
Endpoint address:	07 Direction: IN
Attributes:		02 Transfer type: Bulk
Max.packet size:	0040
Polling interval:	20 32 ms

Endpoint descriptor:
Endpoint address:	05 Direction: OUT
Attributes:		02 Transfer type: Bulk
Max.packet size:	0040
Polling interval:	20 32 ms

Interface descriptor:
Interface number:	05
Alternate setting:	00
Endpoints:		03
Class:			FF Vendor Specific
Subclass:		FF
Protocol:		FF
Interface string:	00

Endpoint descriptor:
Endpoint address:	08 Direction: IN
Attributes:		03 Transfer type: Interrupt
Max.packet size:	0040
Polling interval:	05 5 ms

Endpoint descriptor:
Endpoint address:	09 Direction: IN
Attributes:		02 Transfer type: Bulk
Max.packet size:	0040
Polling interval:	20 32 ms

Endpoint descriptor:
Endpoint address:	06 Direction: OUT
Attributes:		02 Transfer type: Bulk
Max.packet size:	0040
Polling interval:	20 32 ms

Interface descriptor:
Interface number:	06
Alternate setting:	00
Endpoints:		03
Class:			FF Vendor Specific
Subclass:		FF
Protocol:		FF
Interface string:	00

Endpoint descriptor:
Endpoint address:	0A Direction: IN
Attributes:		03 Transfer type: Interrupt
Max.packet size:	0040
Polling interval:	05 5 ms

Endpoint descriptor:
Endpoint address:	0B Direction: IN
Attributes:		02 Transfer type: Bulk
Max.packet size:	0040
Polling interval:	20 32 ms

Endpoint descriptor:
Endpoint address:	07 Direction: OUT
Attributes:		02 Transfer type: Bulk
Max.packet size:	0040
Polling interval:	20 32 ms
Posted in 未分類 | Leave a comment

LPC1768 RTC メモ

水晶振動子36.768kHzの接続と適当なコンデンサの接続が必要。
lpcxpresso LPC1768では12pF 。lpcxpresso LPC1769では5pF 。22pFでも動いた。
(最近の水晶は低容量でよいらしいが詳細は不明。cf."Most modern RTC oscillators do not work any more with load capacitance >= 10pF.")

VDD(REG)(3V3)無効時VBAT 消費電流 →1uA
※データシートによると1.1uAなので妥当な値。CR2032(220mAh)なら10年以上持つ。

VDD(REG)(3V3)有効時
0.6~0.7uA程度(本来は0にできるはずなのでリーク電流か?)
※データシートによると530nAなので妥当な値。

以下、データシートより

LPC1768のRTCではバックアップ電池を入れているにも関わらずRTCがリセットされるという情報があるが、lpcxpressoの基板上のダイオードの問題らしい。
参考:http://www.phoenix-c.or.jp/~olfa/lpcxpresso/16_rtc_oscf.html

自分で組んだ回路では特に問題は発生しなかった。

※電流はP-16で測定

Posted in LPC17XX, メモ | Leave a comment