本帖最后由 JK_alvin 于 2015-1-4 11:27 编辑
STM32F103VCT6,打算用FSMC与cpld通信,现在利用A0~A23以及NWE、NOE、NE、NADV来连接,现象是:
①STM32f101VC的低16位地址是和数据线复用的,目前NADV信号一直维持高电平不变;
②数据地址线波形感觉异常不是方波,电平拉高以后,下降沿是斜坡220us左右变低(有点像接了电容);
#define GPIO_PinD_Data (GPIO_Pin_14| GPIO_Pin_15| GPIO_Pin_0 | GPIO_Pin_1 |\
GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10)
#define GPIO_PinE_Data (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)
#define GPIO_PinD_Addr (GPIO_Pin_11| GPIO_Pin_12| GPIO_Pin_13)
#define GPIO_PinE_Addr (GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_6)
#define GPIO_PinB_NADV GPIO_Pin_7
#define GPIO_PinD_NWE GPIO_Pin_5
#define GPIO_PinD_NOE GPIO_Pin_4
#define GPIO_PinD_NE1 GPIO_Pin_7
/* GPIOD FSMC数据/地址线初始化 */
GPIO_InitStructure.GPIO_Pin = GPIO_PinD_Data | GPIO_PinD_Addr | GPIO_PinD_NWE |GPIO_PinD_NOE | GPIO_PinD_NE1;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //复用推挽输出
GPIO_Init(GPIOD, &GPIO_InitStructure);
/* GPIOE FSMC数据/地址线初始化 */
GPIO_InitStructure.GPIO_Pin = GPIO_PinE_Data | GPIO_PinE_Addr;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //复用推挽输出
GPIO_Init(GPIOE, &GPIO_InitStructure);
/* GPIOB FSMC 锁存线初始化 */
GPIO_InitStructure.GPIO_Pin = GPIO_PinB_NADV;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //复用推挽输出
GPIO_Init(GPIOB, &GPIO_InitStructure);
void FSMC_Configuration()
{
FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
FSMC_NORSRAMTimingInitTypeDef FSMC_ReadWriteTimingStruct;
//-- FSMC 时序配置 ------------------------------------------------------
FSMC_ReadWriteTimingStruct.FSMC_AddressSetupTime = 0x0a;
FSMC_ReadWriteTimingStruct.FSMC_AddressHoldTime = 0x0a;
FSMC_ReadWriteTimingStruct.FSMC_DataSetupTime = 0x0a;
FSMC_ReadWriteTimingStruct.FSMC_BusTurnAroundDuration = 0x02;
FSMC_ReadWriteTimingStruct.FSMC_CLKDivision = 0x00;
FSMC_ReadWriteTimingStruct.FSMC_DataLatency = 0x00;
FSMC_ReadWriteTimingStruct.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_NOR;
FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
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_AsyncWait = FSMC_AsyncWait_Disable;
FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &FSMC_ReadWriteTimingStruct;
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &FSMC_ReadWriteTimingStruct;
FSMC_NORSRAMInit (&FSMC_NORSRAMInitStructure);
// Enable FSMC Bank1_SRAM Bank
FSMC_NORSRAMCmd (FSMC_Bank1_NORSRAM1, ENABLE);
}
谢谢。。。。
【1】FSMC_WrapMode_Disable,在设置了非对齐模式下,扩展后的地址必须考虑(MCU地址会向右一位);
【2】我打开了systick,这会影响到脉冲的波形,具体原因还在检查;
谢谢 @mmuuss586 提供的资料!!! |