咨询ch32v307 FSMC使用问题

FSMC异步传输第一次读取的数据为0,后续读取正常是怎么回事?用逻辑分析仪捕获到数据总线上是有正常数据的。

异步传输等待信号在手册中没有详细的介绍,有没有相关的介绍和时序图。

1690506201136490.png

1690506201163366.png

FSMC的配置

RWTiming.FSMC_AddressSetupTime = 0x01;

    RWTiming.FSMC_AddressHoldTime = 0x00;

    RWTiming.FSMC_DataSetupTime = 0x01;

    RWTiming.FSMC_BusTurnAroundDuration = 0x00;

    RWTiming.FSMC_CLKDivision = 0x00;

    RWTiming.FSMC_DataLatency = 0x00;

    RWTiming.FSMC_AccessMode = FSMC_AccessMode_A;


    FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1;

    FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Enable;

    FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;

    FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;

    FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode =FSMC_BurstAccessMode_Disable;

    FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;

    FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait=FSMC_AsynchronousWait_Enable;

    FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;

    FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;

    FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;

    FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;

    FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Enable;

    FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;

    FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &RWTiming;

    FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &RWTiming;


    FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);

    FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE);


读写的程序

*(vu16*)(FSMC_SRAM_BASE + 0x2) = 0xAA55;

    *(vu16*)(FSMC_SRAM_BASE + 0x4) = 0x55AA;

    rd16_1 = *(vu16 *)(FSMC_SRAM_BASE + 0x2);

    rd16_2 = *(vu16 *)(FSMC_SRAM_BASE + 0x4);

    printf("0x%04X\n", rd16_1);

    printf("0x%04X\n", rd16_2);


    volatile uint16_t *pdat = (volatile uint16_t *)FSMC_SRAM_BASE;

    for (int i = 0; i < 1024; i++) {

        *pdat = i;

        pdat += 2;

    }


    pdat = (volatile uint16_t *)FSMC_SRAM_BASE;

    for (int i = 0; i < 1024; i++) {

        rx_buf[i] = *pdat;

        pdat += 2;

    }



    print_buffer(rx_buf, 1024);


您好,测试了一下发现是正常的,附上测试程序,可以将vu16*类型改成u16*试一下,后续有问题可以邮箱联系:kx@wch.cn

icon_rar.gifFSMC_SRAM.zip

image.png


多谢,改为u16*确实可以了。

关于wait信号的说明有么有呢?



只有登录才能回复,可以选择微信账号登录