8,367
edits
Changes
→40pin SPI test
# According to the schematic diagram of the 40pin interface, the spi available for Orange Pi CM4 is spi3
::[[File:cm4-img262.png]]
<ol start="2" style="list-style-type: decimal;">
<li><p>In the linux system, the SPI 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 SPI configuration you want to open</li></ol>
[[File:cm4-img265.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>Then select'''<Reboot>''' Restart the system for the configuration to take effect</li></ol>
[[File:cm4-img268.png]]
</ol></li></ol>
<ol start="3" style="list-style-type: decimal;">
<li>After restarting, enter the system to check whether there is a '''spidev3.0''' device node in the Linux system. If it exists, it means that SPI3 has been set up and can be used directly</li></ol>{| class="wikitable" style="width:800px;" |-|
orangepi@orangepi:~$ '''ls /dev/spidev3.0'''
/dev/spidev3.0
|}</ol>
<ol start="4" style="list-style-type: decimal;">
<li>Do not short-circuit the mosi and miso pins of SPI3 first, and the output result of running spidev_test is as follows, you can see that the data of TX and RX are inconsistent</li></ol>{| class="wikitable" style="width:800px;" |-|
orangepi@orangepi:~$ '''sudo spidev_test -v -D /dev/spidev3.0'''
max speed: 500000 Hz (500 KHz)
TX | FF FF FF FF FF FF '''<span style="color:#FF0000">40 00 00 00 00 95</span>''' FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F0 0D | ......@.…▒..................▒. RX | FF FF FF FF FF FF '''FF FF FF FF FF FF''' FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF | ............................….
RX | FF FF FF FF FF FF '''<span style="color:#FF0000">FF FF FF FF FF FF</span>''' FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF | ............................….
|}
</ol>
<ol start="5" style="list-style-type: decimal;">
<li>Then short-circuit the two pins of mosi (pin 19 in the 40pin interface) and miso (pin 21 in the 40pin interface) of SPI3 and run the output of spidev_test as follows, you can see the sending and receiving same data</li></ol>
[[File:cm4-img269.png]]
{| class="wikitable" style="width:800px;" |-|
orangepi@orangepi:~$ '''sudo spidev_test -v -D /dev/spidev3.0'''
max speed: 500000 Hz (500 KHz)
TX | FF FF FF FF FF FF '''<span style="color:#FF0000">40 00 00 00 00 95</span>''' FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F0 0D | ......@.…▒..................▒.
RX | FF FF FF FF FF FF '''<span style="color:#FF0000">40 00 00 00 00 95</span>''' FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F0 0D | ......@.…▒..................▒.|}</ol><span id="pin-i2c-test"></span>
=== 40pin I2C test ===