接口连接:#CS-------FSMC_NE1 #INT-------FSMC_NWAIT A0--------FSMC_A15 #RD--------FSMC_NOE #WR-------FSMC_NWE 接口配置:GPIO_InitTypeDef GPIO_InitStructure; RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE); /* ʹÄÜ FSMC, GPIOD, GPIOE, GPIOF, GPIOG ºÍ AFIO ʱÖÓ */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE | RCC_APB2Periph_GPIOF | RCC_APB2Periph_GPIOG | RCC_APB2Periph_AFIO, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOD, &GPIO_InitStructure); /*FSMCÊý¾ÝÏßFSMC_D[0:7]³õʼ»¯£¬ÍÆÍ츴ÓÃÊä³ö*/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_14 |GPIO_Pin_15; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOD, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 |GPIO_Pin_10; GPIO_Init(GPIOE, &GPIO_InitStructure); /*FSMCµØÖ·ÏßFSMC_A15³õʼ»¯£¬ÍÆÍ츴ÓÃÊä³ö*/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; GPIO_Init(GPIOG, &GPIO_InitStructure); /*FSMC NOEºÍNWE³õÊÔ»¯£¬ÍÆÍ츴ÓÃÊä³ö*/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 |GPIO_Pin_5; GPIO_Init(GPIOD, &GPIO_InitStructure); /*FSMC NE1³õÊÔ»¯£¬ÍÆÍ츴ÓÃÊä³ö*/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; GPIO_Init(GPIOD, &GPIO_InitStructure); /*FSMC_NWAIT³õÊÔ»¯£¬ÊäÈë*/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOD, &GPIO_InitStructure); FSMC配置: FSMC_NORSRAMInitTypeDef init; FSMC_NORSRAMTimingInitTypeDef timing; /*-- FSMC Configuration ------------------------------------------------------*/ /*----------------------- SRAM Bank 1 ----------------------------------------*/ /* FSMC_Bank1_NORSRAM1 configuration */ timing.FSMC_AddressSetupTime = 0; timing.FSMC_AddressHoldTime = 0; timing.FSMC_DataSetupTime = 2; timing.FSMC_BusTurnAroundDuration = 0; timing.FSMC_CLKDivision = 0; timing.FSMC_DataLatency = 0; timing.FSMC_AccessMode = FSMC_AccessMode_A; init.FSMC_Bank = FSMC_Bank1_NORSRAM1; init.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; init.FSMC_MemoryType = FSMC_MemoryType_SRAM; init.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_8b; init.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable; init.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable; /* ×¢Òâ¾É¿âÎÞÕâ¸ö³ÉÔ± */ init.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low; init.FSMC_WrapMode = FSMC_WrapMode_Disable; init.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState; init.FSMC_WriteOperation = FSMC_WriteOperation_Enable; init.FSMC_WaitSignal = FSMC_WaitSignal_Disable; init.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable; init.FSMC_WriteBurst = FSMC_WriteBurst_Disable; init.FSMC_ReadWriteTimingStruct = &timing; init.FSMC_WriteTimingStruct = &timing; FSMC_NORSRAMInit(&init); /* - BANK 1 (of NOR/SRAM Bank 1~4) is enabled */ FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE); 地址配置:#define CH376_DAT_PORT (*( vu32 *)0x60000000) // A15 = 0, CS = 0 #define CH376_CMD_PORT (*( vu32 *)0x60008000) // A15 = 1, CS = 0 配置完后测试通信 /* 测试单片机与CH376之间的通讯接口 */ // 发送测试命令 xWriteCH376Cmd(CMD11_CHECK_EXIST); // 发送测试数据 xWriteCH376Data(0x65); // 读数据 u8Result = xReadCH376Data(); u8Result 始终返回0x5f 求教有没有人遇到同样问题,怎么解决的啊 从上往下1:WR 2:RD 3:A0 4:NE1 5:D1(其中一位数据) 写一个数据时,写信号产生了几个周期 ,不正常。。。。。。这是怎么回事? CH376并口时序参数: |
RE:求教stm32 + FSMC +CH376设计问题
RE:求教stm32 + FSMC +CH376设计问题
RE:求教stm32 + FSMC +CH376设计问题
用FSMC时,要计算好时间,详细看看CH376的时序要求,
程序上FSMC配置部分需要修改一下
RE:求教stm32 + FSMC +CH376设计问题
timing.FSMC_DataSetupTime = 2;
我知道要调节这两个参数我计算出timing.FSMC_AddressSetupTime = 0;
timing.FSMC_DataSetupTime = 4;是可以的问题是这样配置后还是会在第一个写使能之后,后面又跟上3个写使能
回复:求教stm32 + FSMC +CH376设计问题
RE:求教stm32 + FSMC +CH376设计问题
简单起见,可以使用IO模拟时序,效率没有FSMC高,但是够用了。