Increase SPI data transferring speed!

General discussion on mikroBasic PRO for PIC32.
Post Reply
Author
Message
Const50
Posts: 124
Joined: 28 Oct 2010 15:08
Location: West Siberia, Tomsk

Increase SPI data transferring speed!

#1 Post by Const50 » 07 Dec 2016 14:40

What we see when read a seqence of bytes (look in attach): 24 MHz SPI clock in byte packet and then 800 nsec sleeping between the packets!
As a result - the fact data transferring is no more than 400KB/sec@24MHz SPICLK!
mE developers, remove the gap and the speed will increase more than twice!
Attachments
pic_101_2.jpg
pic_101_2.jpg (104.81 KiB) Viewed 6170 times
Last edited by Const50 on 01 Jan 2017 06:36, edited 1 time in total.

User avatar
nadir.celebic
mikroElektronika team
Posts: 465
Joined: 15 Jun 2016 13:19

Re: Increase SPI data tranferring speed!

#2 Post by nadir.celebic » 08 Dec 2016 14:57

Hi,

Can you send me the minimal project that represents this issue,
packed in the zip file, so I could test it?

Please tell me what kind of hardware do you use?

Regards,
Nadir

Const50
Posts: 124
Joined: 28 Oct 2010 15:08
Location: West Siberia, Tomsk

Re: Increase SPI data tranferring speed!

#3 Post by Const50 » 10 Dec 2016 12:07

Where to send? Address?

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: Increase SPI data tranferring speed!

#4 Post by Dany » 10 Dec 2016 18:29

Const50 wrote:What we see when read a seqence of bytes (look in attach): 24 MHz SPI clock in byte packet and then 800 nsec sleeping between the packets! As a result - the fact data transferring is no more than 400KB/sec@24MHz SPICLK!
mE developers, remove the gap and the speed will increase more than twice!
Some things in your picture suggest that the reading was done from an SD card, which gives certainly a delay between bytes.
Additionally it suggests the reading was done via a fat32 library, which will give a delay between sectors (not visible however between 2 bytes).
See also http://forum.mikroe.com/viewtopic.php?f ... lit=+speed for previous discussions about SPI and Fat.
See http://forum.mikroe.com/viewtopic.php?f ... 15#p253124 for some raw speed measurements (no SD card, no fat).
Can you show the code (and the PIC confuration) used in your test? Thanks in advance.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

Const50
Posts: 124
Joined: 28 Oct 2010 15:08
Location: West Siberia, Tomsk

Re: Increase SPI data tranferring speed!

#5 Post by Const50 » 11 Dec 2016 05:15

Yes the SD gives delay, but far not 800 nsec, we tested it with 3 different SD manufacturer.
No, here is been used FAT16 and SD 2GB. But you right, between sectors there is a gap, but its size not influences so, as the gap between bytes.
The code is standard your MMCFAT16 library:

Code: Select all

       BSTCount = 19326                              ' bytes, the size of file WF.wbf
       MMC_FAT_ASSIGN ("WF.wbf", 0)            ' preparation for reading from SD              (do you remember, we had the problem with this line with another PIC, PIC220F?
       MMC_FAT_RESET(BSTCount)                  ' file variable set to first byte (position)
       MMC_FAT_READN(@fdata,BSTCount-1)    ' Read bytes from file WF.wbf to RAM PIC
On the picture we see the sequence of sectors reading. We see the gaps between sectors are big, but less than the sector reading time. When we read a byte, its time is 2.5 times more than that for a byte reading.
Attachments
470.png
470.png (324.32 KiB) Viewed 6125 times
pic_102_4.jpg
pic_102_4.jpg (151.02 KiB) Viewed 6125 times

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: Increase SPI data tranferring speed!

#6 Post by Dany » 11 Dec 2016 16:28

I see that you are using only an 48 Mhz CPU clock. The measurements I did myself were with a 80 Mhz CPU clock. The gap between bytes also depends on the clock speed.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

Const50
Posts: 124
Joined: 28 Oct 2010 15:08
Location: West Siberia, Tomsk

Re: Increase SPI data tranferring speed!

#7 Post by Const50 » 12 Dec 2016 06:05

The 48 MHz limited by HW SPI "PIC32MX470F512H: Communication interfaces: •Two 4-wire SPI modules (25 Mbps)". What MCU PIC did you used with 40 MHz SPI? Do you mean PIC32MZ?
Last edited by Const50 on 15 Dec 2016 03:37, edited 2 times in total.

User avatar
nadir.celebic
mikroElektronika team
Posts: 465
Joined: 15 Jun 2016 13:19

Re: Increase SPI data tranferring speed!

#8 Post by nadir.celebic » 13 Dec 2016 17:42

Hi @Const50,

I apologize for the delayed reply.
You can attach here or in the PM.

Best Regards,
Nadir

Const50
Posts: 124
Joined: 28 Oct 2010 15:08
Location: West Siberia, Tomsk

Re: Increase SPI data tranferring speed!

#9 Post by Const50 » 15 Dec 2016 01:27

Look at message at 11 dec abowe.

User avatar
nadir.celebic
mikroElektronika team
Posts: 465
Joined: 15 Jun 2016 13:19

Re: Increase SPI data tranferring speed!

#10 Post by nadir.celebic » 16 Dec 2016 17:58

Hi @Const50,

I will investigate this, and get back to you.

Regards,
Nadir

Post Reply

Return to “mikroBasic PRO for PIC32 General”