Difference between revisions of "Jetson/I2C"
(→I2C busses on Jetson TK1: Linked to a discussion on forum) |
(Added a link to an I2C LED display tutorial) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 188: | Line 188: | ||
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- | 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- | ||
70: -- -- -- -- -- -- -- -- | 70: -- -- -- -- -- -- -- -- | ||
+ | |||
+ | |||
+ | == Add an I2C 7-segment LED display to Jetson TK1 == | ||
+ | A nice tutorial on using I2C to control a 4-character 7-segment LED display is [http://jetsonhacks.com/2015/10/25/4-character-7-segment-led-over-i2c-nvidia-jetson-tk1/ here]. | ||
+ | |||
+ | |||
+ | == Add a Battery-backed Real-Time-Clock (RTC) to Jetson TK1 == | ||
+ | Jetson TK1 contains an RTC chip to hold the time & date for upto 1 hour without power, but if you want to keep time for longer periods without power, and the board can't grab the time & date from an NTP clock server on the network or internet, then you can try to modify the onboard RTC or add your own RTC module, as discussed [https://devtalk.nvidia.com/default/topic/770603/embedded-systems/i2c-port-name-and-i2cbus-number/post/4397340/#4397340 on the forum]. There is also some code that uses the Jetson TK1's RTC to turn the board back on after several minutes, shown [https://gist.github.com/RafaelKa/b1cbb4990a04134dcc03 here]. | ||
+ | |||
+ | |||
+ | == Access PMIC registers in Jetson TK1 (AMS AS3722) == | ||
+ | i2cdump PORT SLAVE_ADDR | ||
+ | $ sudo i2cdump -f -y 4 0x40 | ||
+ | i2cset PORT SLAVE_ADDR REG VALUE | ||
+ | $ sudo i2cset -f -y 4 0x40 0x58 0x05 | ||
+ | i2cget PORT SLAVE_ADDR REG | ||
+ | $ sudo i2cget -f -y 4 0x40 0x58 |
Latest revision as of 05:22, 19 May 2016
Contents
I2C busses on Jetson TK1
There are six I2C busses available on Tegra K1, and four are made available on the expansion header.
- GEN1_I2C on (2x25) J3A1 50-pin expansion port and J3A2 (3x25) 75-pin expansion port
- GEN2_I2C on (2x25) J3A1 50-pin expansion port
- PWR_I2C on (3x25) J3A2 75-pin expansion port
- CAM_I2C on (3x25) J3A2 75-pin expansion port
Note that many of the I2C pins are tolerant of both 1.8V and 3.3V operation, such as all the CAM_I2C_* pins, but it defaults to 1.8V operation. The forum has more details.
Schematics
Pinouts
To quickly test I2C busses operation
Preparation
$ sudo apt-get update $ sudo apt-get install -y i2c-tools
N.B. the package is included in the Universe
ubuntu@tegra-ubuntu:~$ apt-cache policy i2c-tools i2c-tools:
Installed: (none) Candidate: 3.1.0-2 Version table: 3.1.0-2 0 500 http://ports.ubuntu.com/ubuntu-ports/ trusty/universe armhf Packages
Listing installed busses
$ sudo i2cdetect -l i2c-0 i2c Tegra I2C adapter I2C adapter i2c-1 i2c Tegra I2C adapter I2C adapter i2c-2 i2c Tegra I2C adapter I2C adapter i2c-3 i2c Tegra I2C adapter I2C adapter i2c-4 i2c Tegra I2C adapter I2C adapter i2c-5 i2c Tegra I2C adapter I2C adapter
Scanning each I2C bus
Normal probing
$ sudo i2cdetect -y 0 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- 50: -- -- -- -- -- -- 56 -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --
$ sudo i2cdetect -y 1 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --
$ sudo i2cdetect -y 2 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --
$ sudo i2cdetect -y 3 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- 37 -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --
$ sudo i2cdetect -y 4 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: UU -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --
$ sudo i2cdetect -y 5 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --
Probing using SMBus "read byte" commands
$ sudo i2cdetect -y -r 0 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- 50: -- -- -- -- -- -- 56 -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --
$ sudo i2cdetect -y -r 1 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --
$ sudo i2cdetect -y -r 2 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --
$ sudo i2cdetect -y -r 3 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- 37 -- -- 3a 3b -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --
$ sudo i2cdetect -y -r 4 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: UU -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --
$ sudo i2cdetect -y -r 5 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --
Add an I2C 7-segment LED display to Jetson TK1
A nice tutorial on using I2C to control a 4-character 7-segment LED display is here.
Add a Battery-backed Real-Time-Clock (RTC) to Jetson TK1
Jetson TK1 contains an RTC chip to hold the time & date for upto 1 hour without power, but if you want to keep time for longer periods without power, and the board can't grab the time & date from an NTP clock server on the network or internet, then you can try to modify the onboard RTC or add your own RTC module, as discussed on the forum. There is also some code that uses the Jetson TK1's RTC to turn the board back on after several minutes, shown here.
Access PMIC registers in Jetson TK1 (AMS AS3722)
i2cdump PORT SLAVE_ADDR
$ sudo i2cdump -f -y 4 0x40
i2cset PORT SLAVE_ADDR REG VALUE
$ sudo i2cset -f -y 4 0x40 0x58 0x05
i2cget PORT SLAVE_ADDR REG
$ sudo i2cget -f -y 4 0x40 0x58