jennyzhaojie 发表于 2025-1-10 20:44

【MCXN947开发板测评】 MT35XL512读写功能测试

<p>在MCXN947开发板上,除了有QSPI型存储器W25Q64,还有另一种存储器MT35XL512,其电路如图1所示。</p>

<p> &nbsp;</p>

<p>图1 存储器电路</p>

<p>&nbsp;</p>

<p>该存储器的测试主程序为:</p>

<pre>
<code class="language-cpp">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) &amp;&amp; FLASH_ADESTO
    status = flexspi_nor_get_vendor_id(EXAMPLE_FLEXSPI, &amp;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) &amp;&amp; FLASH_ADESTO)
    status = flexspi_nor_get_vendor_id(EXAMPLE_FLEXSPI, &amp;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) &amp;&amp; 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 &lt; 0xFFU; i++)
    {
      s_nor_program_buffer = 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) &amp;&amp; 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)
    {
    }
}
</code></pre>

<p>&nbsp;</p>

<p>经程序的编译和下载,其显示效果如图2所示。说明该存储器的芯片ID为0XEF,经测试读写正常。</p>

<p> &nbsp;</p>

<p>图2 测试结果</p>

<p>&nbsp;</p>
页: [1]
查看完整版本: 【MCXN947开发板测评】 MT35XL512读写功能测试