LoginSignup
0
0

More than 1 year has passed since last update.

LPC812MAXのI2CのIDのスキャンプログラム

Last updated at Posted at 2022-09-03

x IDが7ビット系と8ビット系でいろいろ間違っている(9/4修正済み)

x mbed2リビジョン144
x リビジョン変更が出来るひとむけ

目的
I2Cとシリアルのテスト

よって0x46と0x9Eが繋がっている

o_con719.jpg

o_con720.jpg

小改良



//i2c_scan_id_812_3

#include "mbed.h"

//        TX      RX
Serial pc(USBTX, USBRX); //812

//       SDA    SCL
I2C i2c(A4, A5); //812

//メイン関数
int main()
{

    int hex1[] = {
        '0','1','2','3','4','5','6','7',
        '8','9','A','B','C','D','E','F'
    };

    for(int add1=1; add1<=127; add1++) {
        if ( i2c.write( (add1<<1), "@", 1) == 0) {

            pc.putc( hex1[ (add1<<1) >>    4 ]  );
            pc.putc( hex1[ (add1<<1) &  0x0f ]  );
            pc.putc( ',' );

        }//if

        wait_ms(50);

    }//for

    //無限ループ
    while(1) {}

}//main







//i2c_scan_id_812_2

#include "mbed.h"

//         TX    RX
Serial pc(P0_4, P0_0); //812

//       SDA    SCL
I2C i2c(P0_10, P0_11); //812

//メイン関数
int main()
{

    int hex1[] = {
        '0','1','2','3','4','5','6','7',
        '8','9','A','B','C','D','E','F'
    };

    for(int add1=1; add1<=127; add1++) {
        if ( i2c.write( (add1<<1), "@", 1) == 0) {

            pc.putc( hex1[ (add1<<1) >>    4 ]  );
            pc.putc( hex1[ (add1<<1) &  0x0f ]  );
            pc.putc( ',' );

        }//if

        wait_ms(50);

    }//for

    //無限ループ
    while(1) {}

}//main





いろいろ間違い




//i2c_scan_id_812_1

#include "mbed.h"

//         TX    RX
Serial pc(P0_4, P0_0); //812

//       SDA    SCL
I2C i2c(P0_10, P0_11); //812

//メイン関数
int main()
{

    for(int add1=1; add1<127; add1++) {
        if ( i2c.write(add1, "@", 1) == 0) {

            pc.putc( '0' + (add1 >>    4 )  );
            pc.putc( '0' + (add1 &  0x0f )  );
            pc.putc(',');

        }//if

        wait_ms(50);

    }//for

    //無限ループ
    while(1) {}

}//main




o_con833.jpg

-8-

0
0
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
0
0