Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How fast it will be, if we are using parallel port to access an SD card (soft SPI)?

Status
Not open for further replies.

vinodstanur

Advanced Member level 3
Joined
Oct 31, 2009
Messages
751
Helped
114
Reputation
234
Reaction score
114
Trophy points
1,333
Location
Kerala (INDIA)
Activity points
7,054
I was trying to make a linux kernel module to mount an SD card interfaced to parallel port of my PC...
I succcessfully mounted it and I can access the SD volume...

But the speed of accessing the SD is around 15 to 30KB/sec only... I used parapin library and later I tried my own code with outb(value, port) and inb(port) in the software spi and still the speed is low,,,,


So,
any one accessed an SD card with pc parallel port at a good speed of around 500 or 1000KB/sec ?
 

Most parallel ports are limited to 100k - 200k operations per second. If you can output a byte per operation that means 100-200 kByte/s. However most drivers are limited to SPI or 1-bit mode, and default card mode is 400 kHz clock. 4-bit operation at 25 MHz or faster requires modes usually not supported by the parallel port. You might try some ECP or EPP mode hack with the parallel port if you read the technical documentation thoroughly. I do consider a 4-bit operation using EPP mode (bi-directional) and 200 operations per second reasonable feasible (100 kB/s).

For any normal circumstances you will however be limited to a 200 kbit/s operation (25 kByte/s).


See SD card # Transfer modes
 

acually I am controlling pins using

outb(byte_value, port_address);
inb(port_address);


Now can you guess what will be the frequency of a PIN toggling for below code? From that I can guess my SPI clock speed.... At present, I don't have a frequency meter with me...

Code:
while(1) {
         outb(0xff, 0x378);
         outb(0x00, 0x378);
}
 

Code:
gettimeofday( &tp_start, &tzp );
for(i=0; i<10000; i++){
  outb(0xff, 0x378);
  outb(0x00, 0x378);
  }
gettimeofday( &tp_stop,  &tzp );

then I/O operations per second = 20000 / (tp_stop.tv_sec - tp_start.tv_sec)

For more precision.. 20000 / ((tp_stop.tv_sec + tp_stop.tv_usec/1000000) - (tp_start.tv_sec + tp_start.tv_usec/1000000))

Better use (double) and printf("%f", (float) .. ); to make the compiler deal with the numbers the right way. That way you should find out what performance your parallel port has.
 
Yes I measured it and it is around 350KHz....

So now I think there in no way to increase it... is it?
 

Buy a parallel port card?

Consider that SD-card with parallel port SPI is a "hack" and thus not really a long term solution. Use either a dedicated chip for the task or a FPGA/CPLD/MCU that can exploit the full speed. At higher speeds physical routing becomes an issue too.
 

Why would nanosleep() change anything?
 

Yes I agree it is a bit of hack... I am simply doing this mad stuff just for fun and to gain some knowledge in linux kernel... thats all...;-)

Why nanosleep?
 

Its strange thing it will shroten seconds. PC think that is one second schorter. Its strange but works. Just google
and see what other people do.

Hi tpetar,
I couldn't understand how this nanosleep placed in between the for loop will decrease the time taken...
I simply tested it but the frequency is decreasing....

So, pls give me any link which proves this... I googled it but couldn't find....
 

Some of link from google, if you have more time you will find more material :

http://cboard.cprogramming.com/linu...p-system-call-does-some-confusing-things.html

**broken link removed**

http://stackoverflow.com/questions/9396279/consumer-producer-in-c

---------- Post added 09-05-12 at 00:10 ---------- Previous post was 08-05-12 at 23:26 ----------

Short delay
**broken link removed**

**broken link removed**

---------- Post added at 00:12 ---------- Previous post was at 00:10 ----------

http://www.allegro.cc/forums/thread/444640

http://tldp.org/HOWTO/pdf/IO-Port-Programming.pdf

http://www.ibiblio.org/pub/Linux/docs/HOWTO/IO-Port-Programming

---------- Post added at 00:14 ---------- Previous post was at 00:12 ----------

http://compgroups.net/comp.unix.programmer/nanosleep-accuracy-threads/42333

I think you have enough material for now.
 

Two of the links you provided is a forum thread which doesn't have any reply...
From the links, I couldn't find how the nanosleep will increase the frequency(in my case):roll:

Because what I feel is,
Code:
while(1) {
      outb(0x00, 0x378);
      outb(0x255,0x378);
}
will have the maximum frequency... I couldn't believe this could be increased by a nanosleep placed in between the two outs....

Now,
May be I can agree with you if you are suggesting some thing like this - ie by calling a fork and splitting the process into two and making a very small delay in the child process and then switching ON in parent process and switching OFF in child process...
But I couldn't understand how the nanosleep can increase the frequency in my case!! I believe it is not possible... Also I tried nanosleep in between ON OFF and the result is a low frequency.... Did you tried it?
 
Last edited:

I read about nanosleep(), and tried it in several ways, and it still won't increase the performance in number of I/Os. I am more inclined to conclude that the system timers are affected in a faulty way in Linux/Windows and that your knowledge regarding nanosleep() effect on inb()/outb() performance is wrong.

Doing nothing in a tight I/O loop is unlikely to increase performance. Only a faulty SMP setup, system-timer or phase distortion may make it appear so. Suppose there's two CPUs that share a common I/O channel. If one of the CPUs are put into sleep then the other CPU will have access to more I/O capacity.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top