Software QSPI for stm32f103

What could be included in further releases, or for the forum.
User avatar
diger67
Posts: 30
Joined: Thu Sep 10, 2015 12:13 am
Location: Russia, Sankt- Piterburg

Software QSPI for stm32f103

Post by diger67 » Tue May 02, 2017 1:18 am

Many people use stm32f103xxx. But it does not have a QSPI peripheral module. After reading the documentation for memory (w25qxxx), we tried to write functions that allow you to read information from it using this protocol. And that's what happened. If someone is interested in me to put the source, write. Disadvantages include the inability to use DMA and memory extension stm32 and use as a shared space.
https://youtu.be/YQSgpBKaEFI

ag123
Posts: 810
Joined: Thu Jul 21, 2016 4:24 pm

Re: Software QSPI for stm32f103

Post by ag123 » Tue May 02, 2017 11:23 am

i'd think QSPI is still useful for SPI flash devices using QSPI

it seemed stm32 do have QSPI hardware support, but only for specific devices
http://www.st.com/content/ccc/resource/ ... 227538.pdf

even without dma, 4 bit parallel reads could possibly see pretty high throughput

victor_pv
Posts: 1747
Joined: Mon Apr 27, 2015 12:12 pm

Re: Software QSPI for stm32f103

Post by victor_pv » Tue May 02, 2017 2:17 pm

diger67 wrote:Many people use stm32f103xxx. But it does not have a QSPI peripheral module. After reading the documentation for memory (w25qxxx), we tried to write functions that allow you to read information from it using this protocol. And that's what happened. If someone is interested in me to put the source, write. Disadvantages include the inability to use DMA and memory extension stm32 and use as a shared space.
https://youtu.be/YQSgpBKaEFI
STM has an application note showing how to implement a Software SPI port, which uses DMA, interrups and a timer generating the clock signal to reduce overhead.
The DMA controller writes to a small buffer while the CPU processes another buffer organizing the bits in words. It's not exacly fast, way slower than Hardware SPI is, but perhaps if you use the same tricks to do QSPI you can reach 4 times their speed without more overhead.
I do not remember the name of the AN, but was called something like "Software SPI on STM32 slave master..."

racemaniac
Posts: 622
Joined: Sat Nov 07, 2015 9:09 am

Re: Software QSPI for stm32f103

Post by racemaniac » Tue May 02, 2017 2:36 pm

is there any advantage in using this software quadspi iso just the hardware spi?
normally such memory chips support both normal spi and quad spi, and i assume you're still way faster using the hardware spi vs the software quadspi.
or is this a chip that only has quadspi?

User avatar
diger67
Posts: 30
Joined: Thu Sep 10, 2015 12:13 am
Location: Russia, Sankt- Piterburg

Re: Software QSPI for stm32f103

Post by diger67 » Tue May 02, 2017 4:38 pm

racemaniac wrote:is there any advantage in using this software quadspi iso just the hardware spi?
normally such memory chips support both normal spi and quad spi, and i assume you're still way faster using the hardware spi vs the software quadspi.
or is this a chip that only has quadspi?
This and the chips, which are charred by it, support 3 protocols. Four, two bidirectional and SPI. The maximum transfer rate for SIP in F103 is 4.0 Mbit/s, the switching rate of GPIO is 50 MHz. I think that reading the 4-wire bus using the program code will be somewhat faster. In a two-time at least.
Last edited by diger67 on Tue May 02, 2017 4:46 pm, edited 1 time in total.

racemaniac
Posts: 622
Joined: Sat Nov 07, 2015 9:09 am

Re: Software QSPI for stm32f103

Post by racemaniac » Tue May 02, 2017 4:45 pm

diger67 wrote:
racemaniac wrote:is there any advantage in using this software quadspi iso just the hardware spi?
normally such memory chips support both normal spi and quad spi, and i assume you're still way faster using the hardware spi vs the software quadspi.
or is this a chip that only has quadspi?
This and chips, which are charred by it, support 3 protocols. Four, two bidirectional and SPI. The maximum transmission speed for SIP in F103 is 4.0 Mbit / s, the switching speed of GPMI GPMO is 50 MHz. I think to read the 4-wire bus using the program code will be somewhat faster. Once in two.
Officially the spi bus supports 18Mbit/s, and unofficially you can configure one of both spoi ports on the 103 to do 36Mbit/s (and from what we know so far, that works).
If you can get beyond 18Mbit with your software quad spi code, that would be impressive :).

victor_pv
Posts: 1747
Joined: Mon Apr 27, 2015 12:12 pm

Re: Software QSPI for stm32f103

Post by victor_pv » Tue May 02, 2017 4:47 pm

diger67 wrote:
racemaniac wrote:is there any advantage in using this software quadspi iso just the hardware spi?
normally such memory chips support both normal spi and quad spi, and i assume you're still way faster using the hardware spi vs the software quadspi.
or is this a chip that only has quadspi?
This and chips, which are charred by it, support 3 protocols. Four, two bidirectional and SPI. The maximum transmission speed for SIP in F103 is 4.0 Mbit / s, the switching speed of GPMI GPMO is 50 MHz. I think to read the 4-wire bus using the program code will be somewhat faster. Once in two.
Diger, not sure if it was a typo, but the F103 can do Hardware SPI at up 18Mbit officially in SPI1 to 3, and up to 36Mbit unofficially in SPI1.
Are you referring to a flash memory limitation with the 4Mbits?

User avatar
diger67
Posts: 30
Joined: Thu Sep 10, 2015 12:13 am
Location: Russia, Sankt- Piterburg

Re: Software QSPI for stm32f103

Post by diger67 » Tue May 02, 2017 4:51 pm

Wow !! Sorry. Said stupidity, of course, 18 Mbit / s. But even at this speed the 4-wire software bus will win at the SPI.

User avatar
diger67
Posts: 30
Joined: Thu Sep 10, 2015 12:13 am
Location: Russia, Sankt- Piterburg

Re: Software QSPI for stm32f103

Post by diger67 » Tue May 02, 2017 4:57 pm

victor_pv wrote: Diger, not sure if it was a typo, but the F103 can do Hardware SPI at up 18Mbit officially in SPI1 to 3, and up to 36Mbit unofficially in SPI1.
Are you referring to a flash memory limitation with the 4Mbits?
No. The memory in the SIP mode supports a transmission rate of up to 104 MHz.

victor_pv
Posts: 1747
Joined: Mon Apr 27, 2015 12:12 pm

Re: Software QSPI for stm32f103

Post by victor_pv » Tue May 02, 2017 7:13 pm

diger67 wrote:
victor_pv wrote: Diger, not sure if it was a typo, but the F103 can do Hardware SPI at up 18Mbit officially in SPI1 to 3, and up to 36Mbit unofficially in SPI1.
Are you referring to a flash memory limitation with the 4Mbits?
No. The memory in the SIP mode supports a transmission rate of up to 104 MHz.
Ok I see your post above about the SPI speed.
Did you measure what transfer rates you get with the software QSPI?

BTW the application note from STM on software SPI is AN4678.
They did it with an F4, but should work on any MCU. The main difference is that they do single bit, but may give you some ideas to speed up yours with DMA and a timer for clock generation.

Post Reply