Open main menu

Wiki-Orange Pi β

Changes

Orange Pi CM4

349 bytes added, 19:48, 18 September 2023
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 '''&lt;Save&gt;'''Save</li></ol>
[[File:cm4-img266.png]]
</ol>
<ol start="6" style="list-style-type: lower-alpha;">
<li>Then select '''&lt;Back&gt;'''</li></ol>
[[File:cm4-img267.png]]
</ol>
<ol start="7" style="list-style-type: lower-alpha;">
<li>Then select'''&lt;Reboot&gt;''' 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>First 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>Then you can use the '''spidev_test.py''' program in the examples to test the loopback function of the SPI. The '''spidev_test.py''' program needs to specify the following two parameters:</li></ol>
:a. -- '''channel''': Specify the channel number of SPI b. -- '''port''': Specify the port number of SPI
:b. -- '''port''': Specify the port number of SPI
</ol>
<ol start="5" style="list-style-type: decimal;">
<li>Do not short-circuit the mosi and miso pins of SPI3, the output of running spidev_test.py is as follows, you can see that the data of TX and RX are inconsistent</li></ol>{| class="wikitable" style="width:800px;" |-|
root@orangepi:~/wiringOP-Python# '''cd examples'''
Opening device /dev/spidev3.0
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="6" style="list-style-type: decimal;">
<li>Then use the Dupont wire to short-circuit the two pins of txd (pin 19 in the 40pin interface) and rxd (pin 21 in the 40pin interface) of SPI3 and then run the output of spidev_test.py as follows, you can see The data sent and received are the same, indicating that the SPI3 loopback test is normal</li></ol>{| class="wikitable" style="width:800px;" |-|
root@orangepi:~/wiringOP-Python# '''cd examples'''
Opening device /dev/spidev3.0
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-1"></span>
<span id="pin-i2c-test-1"></span>
=== 40pin I2C test ===