能否提供一个CH32V307的FSMC同步方式的例程?

使用如下配置FSMC没有同步时钟输出


void FSMC_SRAM_Init(void)

{

    FSMC_NORSRAMInitTypeDef  FSMC_NORSRAMInitStructure={0};

    FSMC_NORSRAMTimingInitTypeDef  readWriteTiming={0};

    GPIO_InitTypeDef  GPIO_InitStructure={0};


    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE,ENABLE);

    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC,ENABLE);


    /* FSMC_NADV */

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;

    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;

    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

    GPIO_Init(GPIOB, &GPIO_InitStructure);


    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15;

    GPIO_Init(GPIOD, &GPIO_InitStructure);


    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15;

    GPIO_Init(GPIOE, &GPIO_InitStructure);


    readWriteTiming.FSMC_AddressSetupTime = 0x00;

    readWriteTiming.FSMC_AddressHoldTime = 0x00;

    readWriteTiming.FSMC_DataSetupTime = 0x03;

    readWriteTiming.FSMC_BusTurnAroundDuration = 0x00;

    readWriteTiming.FSMC_CLKDivision = 0x00;

    readWriteTiming.FSMC_DataLatency = 0x00;

    readWriteTiming.FSMC_AccessMode = FSMC_AccessMode_D;


    FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1;

    FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Enable;

    FSMC_NORSRAMInitStructure.FSMC_MemoryType =FSMC_MemoryType_PSRAM;

    FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;

    FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode =FSMC_BurstAccessMode_Enable;

    FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;

    FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait=FSMC_AsynchronousWait_Disable;

    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_Disable;

    FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;

    FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &readWriteTiming;

    FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &readWriteTiming;


    FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);

//    FSMC_Bank1->BTCR[0] = 0x00001197;

//    FSMC_Bank1->BTCR[1] = 0x30000300;

    FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE);

}


您好,暂时没有同步模式的例程,关于FSMC同步模式的部分初始化配置,可按照下图配置方式配置看看,若有问题,可将问题发我邮箱(lzs@wch.cn)联系.

Snipaste_2021-12-17_18-54-04.jpg



将FSMC_CLKDivision设置为1后能输出同步时钟。系统时钟为72MHz,AHB分配器为无分频,同步时钟频率只有4MHz,

请问

1、如何提高FSMC的同步时钟频率?

2、如何像STM32一样持续输出同步时钟?

1639809590208576.png

1639809592105494.png



无意中退出调试状态,同步时钟有36MHz。难道CH32V307在调试状态下系统时钟只有8MHz?


您好,正常情况下,调式时和程序正常运行时系统主频应该都是一样不会有变化的,可以检查一下在调式时是不是什么地方出问题切换为内部晶振了,若后续有问题,可将问题发我邮箱(lzs@wch.cn)联系.


FAE你好,按照上图的配置,捕获的FSMC同步通信波形还是有点问题,请问下还有别的什么需要配置么?

(这是一个读操作,NOE和CLK的相位关系异常。)

image.png


您好,已邮件回复你,后续问题可继续通过邮件沟通


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