目的
先週、FON2045E(RT3050)のGPIOを使って、キャラクタ液晶の制御を行ったが、1行(16文字)表示するのに、1.6秒かかってしまっていた。
今回これの高速化を目指す。
受信側(PIC)の高速化によって改善できないかを実験。
結果
1.6秒→0.5秒にまで短縮することができた。
何をやったか
FON側・・・クロック生成をusleep(4ms)からビジータイマー1460μsに変更
PIC側・・・1ms周期の割り込みによるデータサンプリングを480usに変更
デバック出力としてのUART出力をエラー時のみに変更
● クロック生成の変更
GPIOの制御に1.4μs要するので、これを1000回繰り返しただけ。
それで1460μs消費させる。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for(i=0;i<8;i++){ | |
//========================================== | |
//for pic | |
value = 0; | |
tmp = 0; | |
if((c & mask)>0){ value = 1;} | |
//clk reset(L) 1 with data set | |
for(j=0;j<1000;j++){ //1.4us x 1000 = 1460us | |
tmp = (1<<shift_clk); | |
tmp |= (value<<shift_data); | |
tmp &= 0xff; | |
if (ioctl(fd, req, tmp) < 0) { perror("ioctl"); close(fd); return -1; } | |
} | |
//clk set(H) 0 with data set | |
for(j=0;j<1000;j++){ | |
tmp = (value<<shift_data); | |
tmp &= 0xff; | |
if (ioctl(fd, req, tmp) < 0) { perror("ioctl"); close(fd); return -1; } | |
} | |
mask = mask >>1; | |
} |
480μs もう少し攻めても大丈夫な気がするけど、余裕をみて。
PICは4MHzで動作しているので、1サイクルあたり1μs。
割り込み間隔100μsくらいでも 行けそうな気がする。
0 件のコメント:
コメントを投稿