Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : Why is COPY so slow?
Author | Message | ||||
boss Senior Member Joined: 19/08/2011 Location: CanadaPosts: 268 |
Can someone advise me why "COPY" command is so slow? In this case program is very short, but copy time takes incredible 25 sec. boss 09:31:04 B:\>timer=0:COPY "595B.BAS" TO "595C.BCK":? timer 25520 09:32:36 B:\> '=========================================================== ================== 'MAXIMITE BASIC v.3.1 18.3.2012 'AUTHOR: JA 'DEMONSTRACNI PROGRAM POUZITI Shift registru 74HC595 PRO RIZENI 7-SEGMENT LED ' MULTIPLEXOVANEHO DISPLEJE, 500 REFRESH/SEC '====== DEFINICE POUZITI PINU ================================================ LWRITE=14 SCLK=15 SDATA=16 SPIREAD=10 'Funkce SPI nejen posila data, ale take je cte, takze definice RX '====== NASTAVENI POCATECNI LOG UROVNE PINU=================================== Pin(LWRITE)=0 Pin(SCLK)=0 Pin(SDATA)=0 Pin(SPIREAD)=1 '======= NASTAVENI FUNKCE PINU 2-VSTUP,8-VYSTUP ============================== SetPin LWRITE,8 SetPin SCLK,8 SetPin SDATA,8 SetPin SPIREAD,2 '======== DEKLARACE POLI ===================================================== Dim CAS(4) Dim ZNAK(16) Dim ZNAKN(16) '======== PLNENI POLI DATY =================================================== For I=0 To 15 Read ZNAK(I) If I=0 Then ZNAKN(I) =&HFF Else ZNAKN(I)=ZNAK(I) Next I '============= Definice INTERRUPTU =========================================== SetTick 1000,DEJCAS ' INTERRUPT each 1000mS '----------------------------------------------------------- ------------------ READTIME ' First reading '**************** MAIN ******************************************************* '----------------------------------------------------------- ------------------ ' Pulse 0.001 means that Write Pulse is 1uS (10-6 sec) Do D= SPI(SPIREAD,SDATA,SCLK,&H80) D= SPI(SPIREAD,SDATA,SCLK,CAS(0)) Pulse LWRITE,0.001 D= SPI(SPIREAD,SDATA,SCLK,&H40) D= SPI(SPIREAD,SDATA,SCLK,CAS(1)) Pulse LWRITE,0.001 D= SPI(SPIREAD,SDATA,SCLK,&H20) D= SPI(SPIREAD,SDATA,SCLK,CAS(2)) Pulse LWRITE,0.001 D= SPI(SPIREAD,SDATA,SCLK,&H10) D= SPI(SPIREAD,SDATA,SCLK,CAS(3)) Pulse LWRITE,0.001 ' L=L+1 ' PRO MERENI POCTU REFRESH - VYJMOUT APOSTROF If CAS<>0 Then READTIME Loop End ' MAIN '----------------------------------------------------------- ------------------- '*********************************************************** ******************* '=============*INTERRUPT SERVICE*============================================= DEJCAS: CAS=1 IReturn '=========================================================== =================== 'SUBRUTINA PRO CTENI CASU, POUZIVA POUZE GLOBALNI PROMENNE, PROTO JE BEZ PARAM| '----------------------------------------------------------- ------------------- Sub READTIME CAS(3)=ZNAKN(Val(Left$(Time$,1))):CAS(2)=ZNAK(Val(Mid$(Time$ ,2,1))) And &H7F CAS(1)=ZNAK(Val(Mid$(Time$,4,1))):CAS(0)=ZNAK(Val(Mid$(Time$ ,5,1))):CAS=0 'Print L;Chr$(13);: L=0 ' PRO MERENI POCTU REFRESH - VYJMOUT APOSTROF Return '======= DATA FOR 7-SEG DISPLAY ===================================== 'Data &H80,&H40,&H20,&H10 'D1,D2,D3,D4 Data &HC0,&HF9,&HA4,&HB0,&H99,&H92,&H82,&HF8,&H80,&H90 '0-9 Data &H88,&H83,&HC6,&HA1,&H86,&H8E 'A-F |
||||
BobD Guru Joined: 07/12/2011 Location: AustraliaPosts: 935 |
probably takes so long because you are copying to and from the SD card. The writes and the reads are competing for access to the card. |
||||
boss Senior Member Joined: 19/08/2011 Location: CanadaPosts: 268 |
Yes, I was considering the same reason but still a copy time of more than 25 seconds seems be too long. Yesterday I tried to copy a ~5MB file and this lasted the whole night. |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3194 |
I have had a look at the code and it is easy to see why it is slow... the copy is done on a byte by byte basis. Adding some buffering (2KB) made it run over 100 times faster. I will put this in 3.2 (due in about 4 weeks). Geoff Geoff Graham - http://geoffg.net |
||||
boss Senior Member Joined: 19/08/2011 Location: CanadaPosts: 268 |
I thought so. Thank you for explanation. boss |
||||
Print this page |