11
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

RaspberryPi - ENC28J60(SPI-Ethernet)設定

Last updated at Posted at 2016-06-24
  • I2C-RTC, SPI-Ethernet, UART(USB-Serial)を接続の図

    RPiZero_RTC_Ether.jpg

環境

手順

  1. sudo raspi-config

    • SPI有効化
      9 Advanced Options > A5 SPI > Enable
  2. sudo vi /boot/config.txt

    /boot/config.txt以下を最後に追加

...
#dtoverlay=enc28j60 - 25MHzというのがかいてあったので、25Mhzに設定.
dtoverlay=enc28j60,int_pin=25,speed=25000000

3. `sudo reboot`<br>再起動

4. `ifconfig`<br>`eth0`あらわれた?




## その他

### [DOCUMENTATION > HARDWARE > RASPBERRYPI > SPI](https://www.raspberrypi.org/documentation/hardware/raspberrypi/spi/README.md)によると

- SPEED
The CDIV (Clock Divider) field of the CLK register sets the SPI clock speed:

    ```
SCLK = Core Clock / CDIV
If CDIV is set to 0, the divisor is 65536. The divisor must be a 
power of 2. Odd numbers rounded down. The maximum SPI clock rate is 
of the APB clock.
```
 cdiv    speed
    2    125.0 MHz
    4     62.5 MHz
    8     31.2 MHz
   16     15.6 MHz
   32      7.8 MHz
   64      3.9 MHz
  128     1953 kHz
  256      976 kHz
  512      488 kHz
 1024      244 kHz
 2048      122 kHz
 4096       61 kHz
 8192     30.5 kHz
16384     15.2 kHz
32768     7629 Hz

### SPIクロックとスピード
- `pi@raspberrypi:/tmp wget https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz`
- `/tmp` は、tmfs (RAM)
- 実際に設定されるクロックは↑の制限があるので、設定値にちかいものになるらしい。

    - default = 395KB/s

        ```txt:dtoverlay=enc28j60,int_pin=25
Python-2.7.11.tgz   100%[=====================>]  16.08M   395KB/s   in 42s
- 12MHz(おそらく7.8MHz) = 366KB/s 

    ```txt:dtoverlay=enc28j60,int_pin=25,speed=12000000

Python-2.7.11.tgz 100%[=====================>] 16.08M 366KB/s in 43s


    - 25MHz(おそらく15.6MHz) = 543KB/s

        ```txt:dtoverlay=enc28j60,int_pin=25,speed=25000000
Python-2.7.11.tgz   100%[=====================>]  16.08M   543KB/s   in 32s
- 2MHz(おそらく1953kHz) = 134KB/s

    ```txt:dtoverlay=enc28j60,int_pin=25,speed=2000000

Python-2.7.11.tgz 100%[=====================>] 16.08M 134KB/s in 2m 41s




   - 参考: <font color='blue'>**Raspberry Pi 3**</font>のEthernet = 9.57MB/s

        ```txt:参考:RaspberryPi3のEthernet
Python-2.7.11.tgz   100%[=====================>]  16.08M  9.57MB/s   in 1.7s   
11
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?