Arduino Ethernet shield with SD card.

details

Description:

This project describes about the SD card with the Ardunio Shield,where the SD Card can be used for Data logging or to Host Webpages.

Hardware:

Ardunio Shield(w5100)

SD card

Arduino Uno

25

The Arduino Ethernet Shield has two main features:

  1. The Wiz net W5100 Ethernet Chip which makes an Ethernet connection possible for small micro controllers. The W5100 has a Ethernet PHY and a micro controller can use a simple socket API over SPI to communicate over Ethernet.
  2. A Micro-SD card socket which is on the same SPI bus as the W5100 chip. The SD card can be used for data logging or to host web pages/etc.

There might be better or less expensive solutions to connect a micro controller to the Internet, but that Arduino Ethernet Shield is very affordable and easy to use. The shield is available for less than $15 from many online vendors. There is the option to add a PoE (Power over Ethernet) to the shield too (I don’t have this option).

Both the SD card and the W5100 are connected with SPI to the micro controller. The shield is using the Arduino programming (SPI) adapter, and the SPI MISO/MOSI/CLK signals are *not* connected to the Arduino headers! So to have it working with my FRDM boards, I have to route the signals to the header.

Removal of SPI Programming Header

First,  Remove the 2×3 SPI programming socket on the bottom side of the board:

26

Connecting SPI Signals to Header
Next, Wire the SPI Signals MISO, MOSI and CLK to the Arduino header pins:

27

Pin Assignments:

SPI Signals on the header:

Pin 13: CLK (SPI Clock) (to FRDM-KL2Z: PTD1)
Pin 12: MISO (to FRDM-KL2Z: PTD3)
Pin 11: MOSI (to FRDM-KL2Z: PTD2)
Pin 10: ETH CS (Chip Select of W5100) (to FRDM-KL2Z: PTD0)
Pin: 4: SC CS (Chip Select of SD Card) (to FRDM-KL2Z: PTA4)

28

Application with SD Card Driver:

The project ’uses the  FatFS with FreeRTOS. Using multiple Processor Expert components the project is easily built up like with Lego bricks:

29

Concurrent Access to SPI Bus

Because both the SD card and the W5100 are using the same SPI bus, I need to make sure that access to it is protected with a critical section. For this I use a FreeRTOS semaphore.

Enable in FatFS reentrant and protected access to the file system:

 

30

This not only gives me fully reentrant access to the file system (multiple tasks can access the file system without reentrancy problems). It creates as well events for activating/deactivating the bus:

31

These events I can route to my W5100 driver which there could lock/unlock a semaphore to protect access to the SPI bus, both for the SD card driver and for the Ethernet/W5100 driver.

With the Shell I have a command line interface to my application running on the board.

33

With a card inserted, I can mount the file system.

34

Author: Erich Styger

Tags:201802,Arduino Shield W5100,SD  Card

 

 

 

 

 

 

Description:

This project describes about the SD card with the Ardunio Shield,where the SD Card can be used for Data logging or to Host Webpages.

Hardware:

Ardunio Shield(w5100)

SD card

Arduino Uno

25

The Arduino Ethernet Shield has two main features:

  1. The Wiz net W5100 Ethernet Chip which makes an Ethernet connection possible for small micro controllers. The W5100 has a Ethernet PHY and a micro controller can use a simple socket API over SPI to communicate over Ethernet.
  2. A Micro-SD card socket which is on the same SPI bus as the W5100 chip. The SD card can be used for data logging or to host web pages/etc.

There might be better or less expensive solutions to connect a micro controller to the Internet, but that Arduino Ethernet Shield is very affordable and easy to use. The shield is available for less than $15 from many online vendors. There is the option to add a PoE (Power over Ethernet) to the shield too (I don’t have this option).

Both the SD card and the W5100 are connected with SPI to the micro controller. The shield is using the Arduino programming (SPI) adapter, and the SPI MISO/MOSI/CLK signals are *not* connected to the Arduino headers! So to have it working with my FRDM boards, I have to route the signals to the header.

Removal of SPI Programming Header

First,  Remove the 2×3 SPI programming socket on the bottom side of the board:

26

Connecting SPI Signals to Header
Next, Wire the SPI Signals MISO, MOSI and CLK to the Arduino header pins:

27

Pin Assignments:

SPI Signals on the header:

Pin 13: CLK (SPI Clock) (to FRDM-KL2Z: PTD1)
Pin 12: MISO (to FRDM-KL2Z: PTD3)
Pin 11: MOSI (to FRDM-KL2Z: PTD2)
Pin 10: ETH CS (Chip Select of W5100) (to FRDM-KL2Z: PTD0)
Pin: 4: SC CS (Chip Select of SD Card) (to FRDM-KL2Z: PTA4)

28

Application with SD Card Driver:

The project ’uses the  FatFS with FreeRTOS. Using multiple Processor Expert components the project is easily built up like with Lego bricks:

29

Concurrent Access to SPI Bus

Because both the SD card and the W5100 are using the same SPI bus, I need to make sure that access to it is protected with a critical section. For this I use a FreeRTOS semaphore.

Enable in FatFS reentrant and protected access to the file system:

 

30

This not only gives me fully reentrant access to the file system (multiple tasks can access the file system without reentrancy problems). It creates as well events for activating/deactivating the bus:

31

These events I can route to my W5100 driver which there could lock/unlock a semaphore to protect access to the SPI bus, both for the SD card driver and for the Ethernet/W5100 driver.

With the Shell I have a command line interface to my application running on the board.

33

With a card inserted, I can mount the file system.

34

Author: Erich Styger

Tags:201802,Arduino Shield W5100,SD  Card

 

 

 

 

 

 

COMMENTS

Please Login to comment
  Subscribe  
Notify of