测试平台STM32L496,芯片支持最高主频80MHz,QSPI Flash最高支持104MHz,因此不分频,测试每次搬运1KB,2KB,4KB,8KB,测试内部Flash(双区模式),QSPI单芯片,QSPI双芯片模式,分别对比速度,开启全部Cache,使用FIFO和MemoryMap方式访问,校验数据有效.测试1GB传输.
测试代码:
https://github.com/nickfox-taterli/stm32l4_qspi_benchmark
主程序:
int main(void)
{
HAL_Init();
SystemClock_Config();
BSP_QSPI_Init();
// 1KB 数据
for(uint16_t i = 0;i < 0x400;i++){
wData[i] = i;
rData[i] = 0;
}
for(uint16_t i = 0;i < 16;i++){
BSP_QSPI_Erase_Block(i);
}
for(uint16_t i = 0;i < 16;i++){
BSP_QSPI_Write(wData,0x400 * i,0x400);
}
BSP_QSPI_MemoryMappedMode();
HAL_Delay(5);
time_start = HAL_GetTick();
// 1GB 数据传输
for(uint32_t i =0;i < (1024 * 1024) ;i++){
memcpy(&rData,(void *)0x8000000,0x400);
}
time_end = HAL_GetTick();
time_diff = time_end - time_start;
while (time_diff)
{
}
}
速度测试(单位:秒):
内部Flash(0x8000000) | 单一QSPI(0x90000000) | 双区QSPI(0x90000000) | |
1KB | 18.003 | 27.701 | 15.917 |
2KB | 17.813 | 27.275 | 15.551 |
4KB | 17.718 | 27.061 | 15.308 |
8KB | 17.617 | 26.995 | 15.206 |
速度测试(单位:MB/s)
内部Flash(0x8000000) | 单一QSPI(0x90000000) | 双区QSPI(0x90000000) | |
1KB | 56.87940899 | 36.96617451 | 64.33373123 |
2KB | 57.48610565 | 37.54353804 | 65.84785544 |
4KB | 57.79433345 | 37.84043457 | 66.89312778 |
8KB | 58.12567406 | 37.93295055 | 67.34183875 |
奇不奇怪,片外的连续性能居然更快,双区速度大概是1.75倍单一速度.