打印
[活动专区]

【AT-START-F407测评】+W25Q128的读写测试

[复制链接]
492|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
本帖最后由 jinglixixi 于 2021-1-31 01:34 编辑

AT32F407的开发板上较重要的外设要数W25Q128了,其接口的原理图见图1所示。
图1  存储器接口原理图


通过对W25Q128的读写测试,可以为它的应用打下良好地基础,如来构建字库或图库灯,其测试的连接(将短接子切换到存储器一侧)和效果如图2和图3所示。

2 切换连接后


3 测试结果

形成测试的效果的主程序为:
int main(void)
{
UART_Print_Init(115200);
/* To test ext.flash */
SPIM_test();
while(1);
}

辅助测试的功能函数为:
void SPIM_test(void)
{
u16 i=0;
/* Configures the ext.flash */
printf("init SPIM.\r\n");  
FLASH_InitExtFlash();
/* Fill the content to be writed to ext.flash */
for(i=0;i<SPIM_PAGE_SIZE;i++)
{
WriteBuffer[i]=i%256;
}
/* Erases an ext.flash page */
printf("erase one page.\r\n");
FLASH_ErasePage(SPIM_TEST_ADDR);
/* Read an ext.flash page */
memset(ReadBuffer,0,SPIM_PAGE_SIZE);
ReadPage(SPIM_TEST_ADDR, SPIM_PAGE_SIZE, ReadBuffer);
/* Check if the desired page are erased */
for(i=0;i<SPIM_PAGE_SIZE;i++)
{
if(ReadBuffer[i]!=0xff)
{
printf("operate SPIM fail.\r\n");
return;
}   
}

  /* Program an ext.flash page */
printf("write one page.\r\n");
i=0;
while(i<SPIM_PAGE_SIZE)
{
FLASH_ProgramWord (SPIM_TEST_ADDR+i,*(u32 *)(WriteBuffer+i));
i=i+4;
}
/* Read an ext.flash page */
printf("read one page.\r\n");
memset(ReadBuffer,0,SPIM_PAGE_SIZE);
ReadPage(SPIM_TEST_ADDR, SPIM_PAGE_SIZE, ReadBuffer);
/* Check if reading result and writing content are the same */
printf("compare the WriteBuffer/ReadBuffer.\r\n");
for(i=0;i<SPIM_PAGE_SIZE;i++)
{
if(ReadBuffer[i]!=WriteBuffer[i])
{
/* Print the ext.flash testing result */
printf("test SPIM fail.\r\n");
return;
}   
}

/* Print the ext.flash testing result */
printf("test SPIM success!\r\n");
}

基于该功能的读写测试,我们可以探索着拓展出更多新的应用。

1.jpg (96.1 KB )

1.jpg

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

446

主题

2675

帖子

37

粉丝