本帖最后由 li460135301 于 2023-5-30 00:37 编辑
最近打算用AT32F435外挂一篇spi flash做存储,因为看到AT32F435本身支持qspi,想着qspi支持四线制读写,速度和效率肯定高很多。但是测试下来差别基本不大?
我用AT32F435的spi和qspi各挂载了一片w25q64(8MB)。也就是一片用spi驱动,一片用qspi驱动。
测试环境用rt-thread studio,基于SFUD,这里需要说明一下:SFUD的QSPI写入模式目前好像不支持4线写入,所以写入数据也是采用单线写入的。另外,由于AT32F435的rt-thread的BSP中,qspi没有支持dma模式(如果能增加就最好不过了,用户我们自己修改的话太麻烦了),而spi可以开启dma模式。所以这里测试了一下,spi在不开启dma和开启dma模式于qspi的对比。所以该测试并不全面?另外,有不合理的地方,可以讨论,或者雅特力的技术人员有没有更好的提升qspi的速度的方式。谢谢。
另外,qspi(qspi1)的速度采用默认设置50MHZ,实际速度应该是48Mhz,spi(spi2)的速度位AT32F435的spi最大速度36MHZ。
首先,spi默认不开启DMA,进行sf bench测试,结果如下:
msh />sf probe qspi10
[I/SFUD] Find a Winbond flash chip. Size is 8388608 bytes.
[I/SFUD] sf_cmd flash device is initialize success.
[I/SFUD] Probe SPI flash sf_cmd by SPI device qspi10 success.
8 MB sf_cmd is current selected device.
msh />sf bench yes
Erasing the sf_cmd 8388608 bytes data, waiting...
Erase benchmark success, total time: 17.340S.
Writing the sf_cmd 8388608 bytes data, waiting...
Write benchmark success, total time: 32.768S.
Reading the sf_cmd 8388608 bytes data, waiting...
Read benchmark success, total time: 2.060S.
msh />sf probe spi20
[I/SFUD] Find a Winbond flash chip. Size is 8388608 bytes.
[I/SFUD] sf_cmd flash device is initialize success.
[I/SFUD] Probe SPI flash sf_cmd by SPI device spi20 success.
8 MB sf_cmd is current selected device.
msh />sf bench yes
Erasing the sf_cmd 8388608 bytes data, waiting...
Erase benchmark success, total time: 16.881S.
Writing the sf_cmd 8388608 bytes data, waiting...
Write benchmark success, total time: 32.769S.
Reading the sf_cmd 8388608 bytes data, waiting...
Read benchmark success, total time: 8.165S.
可以看到擦除和写入速度几乎一样,而读取速度,qspi的速度位spi的4倍左右,也就是qspi读取一片8MB的SPI flash 要2秒钟。
然后我们开启spi的dma,结果如下:
msh />sf probe qspi10
[I/SFUD] Find a Winbond flash chip. Size is 8388608 bytes.
[I/SFUD] sf_cmd flash device is initialize success.
[I/SFUD] Probe SPI flash sf_cmd by SPI device qspi10 success.
8 MB sf_cmd is current selected device.
msh />sf bench yes
Erasing the sf_cmd 8388608 bytes data, waiting...
Erase benchmark success, total time: 16.439S.
Writing the sf_cmd 8388608 bytes data, waiting...
Write benchmark success, total time: 32.768S.
Reading the sf_cmd 8388608 bytes data, waiting...
Read benchmark success, total time: 2.060S.
msh />sf probe spi20
[I/SFUD] Find a Winbond flash chip. Size is 8388608 bytes.
[I/SFUD] sf_cmd flash device is initialize success.
[I/SFUD] Probe SPI flash sf_cmd by SPI device spi20 success.
8 MB sf_cmd is current selected device.
msh />sf bench yes
Erasing the sf_cmd 8388608 bytes data, waiting...
Erase benchmark success, total time: 16.642S.
Writing the sf_cmd 8388608 bytes data, waiting...
Write benchmark success, total time: 32.768S.
Reading the sf_cmd 8388608 bytes data, waiting...
Read benchmark success, total time: 2.920S.
我们发现,再开启的DMA模式之后,spi读取一片8MB的flash需要2.92s,仅仅比qspi慢了0.9s不到,这个还是再qspi速度比spi高12M的情况下。所以我感觉不合理啊?
不知道是不是我测试的方法问题。还请请教?否则用qspi的意义就不大了,qspi还比spi多占用了两个io。
附件是我测试的工程代码,基于rt-thread studio。
另外,AT32的rt-thread studio的pack最新版本0.1.4的串口有bug,中断函数都采用UART1_IRQHandler(实际应该是USART1_IRQHandler,串口1,2,3,6都是这样),否则串口只能打印不能输入,这个疏忽就很尬尴,每次创建工程,需要自己修改drv_usart.c文件。
|