I am working on a project which has an Arduino Uno board, an Ethernet Shield, and an SD Card which is mounted on the Shield.
It's a basic SD card web server. When I type it's IP address in the browser, then the Arduino fetches the HTML page (.htm) from the SD card and writes it to the browser. It works fine, but here is a problem.
The htm webpage on the SD card is about 64kb in size, and it takes about 16 seconds to load it on the browser. It means that the Arduino writes the page at a rate of 4kbps. This is too slow if it is to load a 64kb page.
And I can literally see the Ethernet Shield struggling as the webpage loads.
I tried it with both SD library and SDfat library. (SDfat was said to be faster than SD) but both gave the same result.
What I think now, is that the Ethernet Shield and SD both use the SPi bus. How it works is that Arduino reads one char at a time from the htm file and write()s it on the Ethernet client. So I think, that this is too complicated and switching the Ethernet and SD on the SPI bus just for one char is very time consuming.
I think that the alternation of the Ethernet and SD on the bus is causing time.
Please can anyone tell if this is actually the problem, or its anything else? And please tell if I can use the SD and Ethernet on two separate SPI buses.
No where in your discussion of the SD card do you account for the fact that the data is ONLY read from the card in 512 byte segments and the library must block until all the 512 bytes have been read.
Paul
SD libraries always have their own 512 byte buffer to read SD card data into or write SD card data from. When you read one or more bytes, the library only moves that number of bytes from it's buffer to your variable. When the library has moved 512 bytes, total, it will physically read another 512 bytes into it's buffer and that takes time!
Paul