Fast SPI on stm32f103cbt6

Working libraries, libraries being ported and related hardware
User avatar
Pito
Posts: 561
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Fast SPI on stm32f103cbt6

Postby Pito » Sun Jan 01, 2017 2:06 pm

Updated Table with SPI.write(buf,size).

stm32_discoverer
Posts: 17
Joined: Sun Jan 01, 2017 10:28 am

Re: Fast SPI on stm32f103cbt6

Postby stm32_discoverer » Sun Jan 01, 2017 2:20 pm

but how activate DMA transfer on SPI1?

User avatar
Pito
Posts: 561
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Fast SPI on stm32f103cbt6

Postby Pito » Sun Jan 01, 2017 2:21 pm

Updated Table with SPI.dmaTransfer(buft, bufr, 1000) transfer timings :)

Code: Select all

uint8 bfs[1000];
uint8 bfr[1000];

void loop() {
  uint32 duration = micros();
 
    //  for (int i = 0; i < 1000; i++){
    //    data = SPI.transfer(0xFF);
    //  }
   
    // SPI.write(bfs, 1000);
   
     SPI.dmaTransfer(bfs, bfr, 1000);
     
  duration = micros() - duration;
  Serial.println(duration);
}
Last edited by Pito on Sun Jan 01, 2017 2:28 pm, edited 4 times in total.

stm32_discoverer
Posts: 17
Joined: Sun Jan 01, 2017 10:28 am

Re: Fast SPI on stm32f103cbt6

Postby stm32_discoverer » Sun Jan 01, 2017 2:26 pm

Pito wrote:Updated Table with SPI.dmaTransfer(buft, bufr, 1000) transfer timings :)

you are very fast :)

stm32_discoverer
Posts: 17
Joined: Sun Jan 01, 2017 10:28 am

Re: Fast SPI on stm32f103cbt6

Postby stm32_discoverer » Sun Jan 01, 2017 3:05 pm

bufs and buft in SPI.dmaTransfer should be the same size?

User avatar
Pito
Posts: 561
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Fast SPI on stm32f103cbt6

Postby Pito » Sun Jan 01, 2017 3:29 pm

SPI sends and receives in parallel, so the buffers shall be the same size.

Not sure how the function
uint8 dmaTransfer(uint8 *transmitBuf, uint8 *receiveBuf, uint16 length);

actually works - as it is seems from timing it is blocking.
My understanding would be you shoot out the data via SPI.dmaTransfer() and do other things afterwards ..
Last edited by Pito on Sun Jan 01, 2017 3:47 pm, edited 1 time in total.

stm32_discoverer
Posts: 17
Joined: Sun Jan 01, 2017 10:28 am

Re: Fast SPI on stm32f103cbt6

Postby stm32_discoverer » Sun Jan 01, 2017 3:41 pm

thank you very much for the info ;)

stevestrong
Posts: 675
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Fast SPI on stm32f103cbt6

Postby stevestrong » Sun Jan 01, 2017 4:39 pm

danieleff wrote:I do not know why is it not called SPI.transfer(buffer, size) like in the arduino reference.

Because SPI.write(buffer, size) only transmits (writes) data, but no data is read form peripheral. Mostly used for SPI display boards.
There is also an SPI.read(buffer,size) function for reading only (actually it writes 0xFF). Used in SDFat.
These are the most commonly used functions.
SPI.transfer(data) is available for single data or multiple DMA driven write/read accesses, as already pointed out. I am not sure where buffered DMA write/read would be useful.


Return to “Libraries & Hardware”

Who is online

Users browsing this forum: No registered users and 1 guest