Raspberry Pie Learning Notes--i2c Tools Learning notes

Source: Internet
Author: User
1. InstallationI2C drive load and rate changes check the blog "Raspberry School notes--I2C device load and rate settings". 2.I2C Bus ScanThe I2cdetect-l command allows you to view the I2C bus on the raspberry pie, and from the results of the return, the raspberry pie contains two I2C buses, and by reading the relevant data, the raspberry pie uses i2c0 for 1 generations, while the Raspberry Pie 2 uses i2c1.
pi@raspberrypi:~$ i2cdetect-l
i2c-0   i2c             bcm2708_i2c.0                           I2C             adapter i2c-1 I2C bcm2708_ I2C.1                           I2C Adapter

3.i2c Device QueryIf the I2C from the device is mounted on the bus, all devices on a I2C bus can be scanned by I2cdetect. You can enter i2cdetect-y 1 through the console, and the results are shown below.
pi@raspberrypi:~$ i2cdetect-y 1 0 1 2 3 4 5 6 7 8 9  a  b  c  d  e          --------------------------: 
-------------------------- ------ 
20:20------------------------------ 
:------------------------------- - 
-------------------------------- 
50:50---------------------------- 
6 0:-------------------------------- 
:----------------  

Description 1:-y is an optional parameter, and if there is a-y parameter there will be a user interaction process, meaning that you want the user to stop using the I2C bus. If this argument is written, there is no interaction, which is typically used in scripts. NOTE 2: Here the I2C bus contains two devices--pcf8574 and AT24C04, from the machine address 0x20 to PCF8574, from the machine address 0x50 and 0x51 for AT24C04, please note that AT24C04 has two I2C address, please see the relevant content of reference 6.4.
4. Register Content ExportThe i2cdump directive allows you to export all of the register contents in a I2C device, such as entering I2cdump-y 1 0x51, to obtain the following:
pi@raspberrypi:~$ i2cdump-y 1 0x51 No size specified (using Byte-data access) 0 1 2 3 4 5 6 7 8 9 a B C
D e F 0123456789abcdef, FF FF FF FF 00:FF FF FF FF FF FF FF FF FF FF FF ......
10:FF, FF FF FF FF FF FF-FF-FF FF FF FF FF FF FF FF ....
20:FF, FF FF FF FF FF FF-FF-FF FF FF FF FF FF FF FF ....
30:FF, FF FF FF FF FF FF-FF-FF FF FF FF FF FF FF FF ....
40:FF, FF FF FF FF FF FF-FF-FF FF FF FF FF FF FF FF ....
50:FF, FF FF FF FF FF FF-FF-FF FF FF FF FF FF FF FF ....
60:FF, FF FF FF FF FF FF-FF-FF FF FF FF FF FF FF FF ....
70:FF, FF FF FF FF FF FF-FF-FF FF FF FF FF FF FF FF ....
80:FF, FF FF FF FF FF FF-FF-FF FF FF FF FF FF FF FF .... 90:FF FF FF-FF FF FF-FF-FF, FF FF FF f .... A0:FF FF FF FF FF FF FF-FF-FF FF-FF FF FF FF FF F .... B0:FF FF FF FF FF the FF FF FF FF the FF FF FF FF FF ff...C0:FF FF FF FF FF FF FF FF FF the FF FF FF FF FF FF ... d0:ff FF-FF FF FF FF FF FF FF FF F------------- F FF FF FF FF FF .... E0:FF FF FF FF FF f FF FF FF FF FF FF FF FF FF-FF ... f0:ff FF FF----------??? FF-FF FF FF FF-FF-FF-FF FF FF FF FF FF ...
I2cdump-y 1 0x51 instructions, the-y representative cancels the user interaction process, executes the instruction directly, 1 represents the I2C bus number, and 0x51 represents the I2C device from the machine address, where the AT24C04 high 256 bytes are selected. Content.
The high 256 bytes in the AT24C04 are still in the factory default state, and all storage addresses are 0XFF in content.
5. Register Content WriteIf you write a byte to a I2C device, you can enter instructions i2cset-y 1 0x50 0x00 0x13-y represents the curve user interaction process, direct execution instruction 1 represents the I2C bus number
0X50 represents the I2C device address, where the lower 256-byte content of AT24C04 is selected
0x00 represents memory address
0x13 represents the specific contents of the memory address

6. Register content read out
pi@raspberrypi:~$ i2cget-y 1 0x50 0x00
0x13

If you read a byte from I2C from the device, you can enter the execution i2cget-y 1 0x50 0x00 to get the following feedback results
-Y represents the curve user interaction process, direct execution instruction 1 represents I2C bus number
0X50 represents the I2C device address, where the lower 256-byte content of AT24C04 is selected
0x00 represents memory address
7. SummaryI2ctools is a simple and useful tool that makes debugging of I2C devices more convenient.

8. Reference materials"1" i2ctools official Reference "2" why AT24C04 have two I2C from the machine address


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.