8,367
edits
Changes
→40pin I2C test
# As can be seen from the table below, the available i2c for Orange Pi CM4 is i2c2, i2c3 and i2c4, a total of three sets of i2c buses
::[[File:cm4-img270.png]]
::{| class="wikitable" style="background-color:#ffffdc;width:800px;" |-| <big>'''As can be seen from the above table, i2c4_m0 and spi3_m0 are multiplexed pins, and both cannot be opened at the same time. i2c3_m0 and uart3_m0 are also multiplexed pins, and both cannot be opened at the same time'''</big>|}
<ol start="2" style="list-style-type: decimal;">
<li><p>In the linux system, the I2C bus in the 40 pin is closed by default, and it needs to be opened manually to use it. The detailed steps are as follows:</p>
<ol style="list-style-type: lower-alpha;">
<li>First run '''orangepi-config''', common users remember to add '''sudo''' permission</li></ol></li></ol>{| class="wikitable" style="width:800px;" |-|
orangepi@orangepi:~$ '''sudo orangepi-config'''
|}</ol>
<ol start="2" style="list-style-type: lower-alpha;">
<li>Then select '''System'''</li></ol>
[[File:cm4-img263.png]]
</ol>
<ol start="3" style="list-style-type: lower-alpha;">
<li>Then select '''Hardware'''</li></ol>
[[File:cm4-img264.png]]
</ol>
<ol start="4" style="list-style-type: lower-alpha;">
<li>Then use the arrow keys on the keyboard to navigate to the position shown in the figure below, and then use the space to select the I2C configuration you want to open</li></ol>
[[File:cm4-img271.png]]
</ol>
<ol start="5" style="list-style-type: lower-alpha;">
<li>Then select '''<Save>''' Save</li></ol>
[[File:cm4-img266.png]]
</ol>
<ol start="6" style="list-style-type: lower-alpha;">
<li>Then select '''<Back>'''</li></ol>
[[File:cm4-img267.png]]
</ol>
<ol start="7" style="list-style-type: lower-alpha;">
<li><p>Then select '''<Reboot>''' Restart the system for the configuration to take effect</p>
<p>[[File:cm4-img268.png]]</p></li></ol>
<!-- --/li></ol>
<ol start="3" style="list-style-type: decimal;">
<li>After starting the Linux system, first confirm that there is an i2c device node under /dev</li></ol>{| class="wikitable" style="width:800px;" |-|
orangepi@orangepi:~# '''ls /dev/i2c-*'''
/dev/i2c-0 '''/dev/i2c-2''' '''/dev/i2c-3''' '''/dev/i2c-4''' /dev/i2c-6|}</ol>
<ol start="4" style="list-style-type: decimal;">
<li>Then connect an i2c device to the i2c pin of the 40pin connector, here we take the ds1307 RTC module as an example</li></ol>
{| class="wikitable" style="width:800px;text-align: center;"
|-
|
[[File:cm4-img284.png]]
</ol>
<ol start="5" style="list-style-type: decimal;">
<li>Then use the '''i2cdetect -y''' command, if the address of the connected i2c device can be detected, it means that i2c can be used normally</li></ol>{| class="wikitable" style="width:800px;" |-| orangepi@orangepi:~$ sudo i2cdetect -y 2 #i2c2 command
orangepi@orangepi:~$ sudo i2cdetect -y 2 3 #i2c2 i2c3 command
[[File:cm4-img272.png]]
</ol>
<ol start="6" style="list-style-type: decimal;">
<li>Then you can run the '''ds1307.py''' test program in the '''examples'''to read the RTC time</li></ol>{| class="wikitable" style="width:800px;" |-|
root@orangepi:~/wiringOP-Python# '''cd examples'''
exit
|}
</ol>
<span id="pin-uart-test-1"></span>
=== 40pin UART test ===