打印
[AIROC™ 蓝牙]

【英飞凌CYW20829测评】+ QSPI外设实验

[复制链接]
151|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
lishuihua|  楼主 | 2024-7-21 17:42 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

本次实验学习QSPI外设。

首先进行外设初始化:
    /* Initialize the Serial flash */
    result = cy_serial_flash_qspi_init(smifMemConfigs[MEM_SLOT_NUM],
            CYBSP_QSPI_D0, CYBSP_QSPI_D1, CYBSP_QSPI_D2, CYBSP_QSPI_D3, NC, NC,
            NC, NC, CYBSP_QSPI_SCK, CYBSP_QSPI_SS, QSPI_BUS_FREQUENCY_HZ);
    check_status("Serial Flash initialization failed", result);


写入之前要先进行擦除操作:
/* Use last sector to erase for flash operation */
    ext_mem_address = (smifMemConfigs[0]->deviceCfg->memSize/2 -
                               smifMemConfigs[0]->deviceCfg->eraseSize *2);

    sectorSize = cy_serial_flash_qspi_get_erase_size(ext_mem_address);
    printf("\r\nTotal Flash Size:%u bytes\r\n",cy_serial_flash_qspi_get_size());

    /* Erase before write */
    printf("\r\n1. Erasing %u bytes of memory\r\n", sectorSize);
    result = cy_serial_flash_qspi_erase(ext_mem_address, sectorSize);
    check_status("Erasing memory failed", result);

    /* Read after Erase to confirm that all data is 0xFF */
    printf("\r\n2.Reading after Erase & verifying that each byte is 0xFF\r\n");
    result = cy_serial_flash_qspi_read(ext_mem_address, PACKET_SIZE, rx_buf);
    check_status("Reading memory failed", result);
    print_array("Received Data", rx_buf, PACKET_SIZE);
    memset(tx_buf, FLASH_DATA_AFTER_ERASE, PACKET_SIZE);
    check_status("Flash contains data other than 0xFF after erase",
            memcmp(tx_buf, rx_buf, PACKET_SIZE));


实验测试结果:

****************** Serial Flash Read and Write ******************


Total Flash Size:1048576 bytes

1. Erasing 4096 bytes of memory

2.Reading after Erase & verifying that each byte is 0xFF

Received Data (64 bytes):
-------------------------
0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF

3. Writing data to memory

Written Data (64 bytes):
-------------------------
0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F
0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1A 0x1B 0x1C 0x1D 0x1E 0x1F
0x20 0x21 0x22 0x23 0x24 0x25 0x26 0x27 0x28 0x29 0x2A 0x2B 0x2C 0x2D 0x2E 0x2F
0x30 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x3A 0x3B 0x3C 0x3D 0x3E 0x3F

4. Reading back for verification

Received Data (64 bytes):
-------------------------
0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F
0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1A 0x1B 0x1C 0x1D 0x1E 0x1F
0x20 0x21 0x22 0x23 0x24 0x25 0x26 0x27 0x28 0x29 0x2A 0x2B 0x2C 0x2D 0x2E 0x2F
0x30 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x3A 0x3B 0x3C 0x3D 0x3E 0x3F

=========================================================

SUCCESS: Read data matches with written data!

=========================================================

使用特权

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

本版积分规则

5

主题

24

帖子

0

粉丝