【MCXN947开发板测评】 MT35XL512读写功能测试
[复制链接]
在MCXN947开发板上,除了有QSPI型存储器W25Q64,还有另一种存储器MT35XL512,其电路如图1所示。
图1 存储器电路
该存储器的测试主程序为:
int main(void)
{
uint32_t i = 0;
status_t status;
uint8_t vendorID = 0;
CLOCK_SetClkDiv(kCLOCK_DivFlexcom4Clk, 1u);
CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH);
BOARD_InitPins();
BOARD_InitBootClocks();
BOARD_InitDebugConsole();
CLOCK_SetClkDiv(kCLOCK_DivFlexspiClk, 2U);
CLOCK_AttachClk(kPLL0_to_FLEXSPI);
flexspi_nor_flash_init(EXAMPLE_FLEXSPI);
PRINTF("\r\nFLEXSPI example started!\r\n");
#if defined(FLASH_ADESTO) && FLASH_ADESTO
status = flexspi_nor_get_vendor_id(EXAMPLE_FLEXSPI, &vendorID);
if (status != kStatus_Success)
{
return status;
}
PRINTF("Vendor ID: 0x%x\r\n", vendorID);
#endif
#if defined(FLASH_ENABLE_OCTAL_CMD)
status = flexspi_nor_enable_octal_mode(EXAMPLE_FLEXSPI);
if (status != kStatus_Success)
{
return status;
}
#endif
#if !(defined(FLASH_ADESTO) && FLASH_ADESTO)
status = flexspi_nor_get_vendor_id(EXAMPLE_FLEXSPI, &vendorID);
if (status != kStatus_Success)
{
return status;
}
PRINTF("Vendor ID: 0x%x\r\n", vendorID);
#endif
PRINTF("Erasing Serial NOR over FlexSPI...\r\n");
status = flexspi_nor_flash_erase_sector(EXAMPLE_FLEXSPI, EXAMPLE_SECTOR * SECTOR_SIZE);
if (status != kStatus_Success)
{
PRINTF("Erase sector failure !\r\n");
return -1;
}
#if defined(CACHE_MAINTAIN) && CACHE_MAINTAIN
DCACHE_InvalidateByRange(EXAMPLE_FLEXSPI_AMBA_BASE + EXAMPLE_SECTOR * SECTOR_SIZE, FLASH_PAGE_SIZE);
#endif
memset(s_nor_program_buffer, 0xFFU, sizeof(s_nor_program_buffer));
memcpy(s_nor_read_buffer, (void *)(EXAMPLE_FLEXSPI_AMBA_BASE + EXAMPLE_SECTOR * SECTOR_SIZE),
sizeof(s_nor_read_buffer));
if (memcmp(s_nor_program_buffer, s_nor_read_buffer, sizeof(s_nor_program_buffer)))
{
PRINTF("Erase data - read out data value incorrect !\r\n ");
return -1;
}
else
{
PRINTF("Erase data - successfully. \r\n");
}
for (i = 0; i < 0xFFU; i++)
{
s_nor_program_buffer[i] = i;
}
status =
flexspi_nor_flash_page_program(EXAMPLE_FLEXSPI, EXAMPLE_SECTOR * SECTOR_SIZE, (void *)s_nor_program_buffer);
if (status != kStatus_Success)
{
PRINTF("Page program failure !\r\n");
return -1;
}
#if defined(CACHE_MAINTAIN) && CACHE_MAINTAIN
DCACHE_InvalidateByRange(EXAMPLE_FLEXSPI_AMBA_BASE + EXAMPLE_SECTOR * SECTOR_SIZE, FLASH_PAGE_SIZE);
#endif
memcpy(s_nor_read_buffer, (void *)(EXAMPLE_FLEXSPI_AMBA_BASE + EXAMPLE_SECTOR * SECTOR_SIZE),
sizeof(s_nor_read_buffer));
if (memcmp(s_nor_read_buffer, s_nor_program_buffer, sizeof(s_nor_program_buffer)) != 0)
{
PRINTF("Program data - read out data value incorrect !\r\n ");
return -1;
}
else
{
PRINTF("Program data - successfully. \r\n");
}
while (1)
{
}
}
经程序的编译和下载,其显示效果如图2所示。说明该存储器的芯片ID为0XEF,经测试读写正常。
图2 测试结果
|