高中生
最后登录1970-1-1
在线时间 小时
注册时间2014-5-17
|
5火花
STM32F103VET6 FSMC访问CPLD,采用NOR方式,地址数据复用,为啥NADV电平一直为高电平呢?程序如下:
void FSMC_Configuration()
{
FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
FSMC_NORSRAMTimingInitTypeDef FSMC_NORSRAMTimingStructure;
GPIO_InitTypeDef GPIO_InitStructure;
/*
FSMC_D0--PD14 FSMC_D1--PD15 FSMC_D2--PD0 FSMC_D3--PD1
FSMC_D4--PE7 FSMC_D5--PE8 FSMC_D6--PE9 FSMC_D7--PE10
FSMC_D8--PE11 FSMC_D9--PE12 FSMC_D10--PE13 FSMC_D11--PE14
FSMC_D12--PE15 FSMC_D13--PD8 FSMC_D14--PD9 FSMC_D15--PD10
FSMC_NOE--PD4 FSMC_NWE--PD5 FSMC_NADV--PB7 FSMC_NE1--PD7
FSMC_A16--PD11 FSMC_A17--PD12 FSMC_A18--PD13 FSMC_A19--PE3
FSMC_A20--PE4 FSMC_A21--PE5 FSMC_A22--PE6 FSMC_A23--PE2
*/
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOD| RCC_APB2Periph_GPIOE, ENABLE);
//设置PD口PD 0,1,4,5,8,9,10,11,12,13,14,15为FSMC模式
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | 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_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOD, &GPIO_InitStructure);
//设置PE口PE 2,3,4,5,6,7,8,9,10,11,12,13,14,15为FSMC模式
GPIO_InitStructure.GPIO_Pin = 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);
//FSMC_NADV
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 ;
GPIO_Init(GPIOB, &GPIO_InitStructure);
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE); //使能FSMC时钟
FSMC_NORSRAMTimingStructure.FSMC_AddressSetupTime = 15; /*地址建立时间期限*/
FSMC_NORSRAMTimingStructure.FSMC_AddressHoldTime = 15; /*地址的持续时间*/
FSMC_NORSRAMTimingStructure.FSMC_DataSetupTime = 15; /*设定数据时间期限*/
FSMC_NORSRAMTimingStructure.FSMC_BusTurnAroundDuration = 15; /*总线转向时间*/
FSMC_NORSRAMTimingStructure.FSMC_CLKDivision = 0; /*CLK时钟输出信号的HCLK周期数表示时间???*/
FSMC_NORSRAMTimingStructure.FSMC_DataLatency = 0; /*指定在获得第一个数据前的时钟周期*/
FSMC_NORSRAMTimingStructure.FSMC_AccessMode = FSMC_AccessMode_B;
FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1; /*指定的FSMC块*/
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块的写操作*/
FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable; /*不可用NWAIT信号*/
FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable; /*禁用扩展模式*/
FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable; /*写操作始终处于异步模式*/
// FSMC_NORSRAMInitStructure.FSMC_AsyncWait = FSMC_AsyncWait_Disable;
FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &FSMC_NORSRAMTimingStructure;
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &FSMC_NORSRAMTimingStructure;
/* FSMC Configuration */
FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);
/* Enable FSMC Bank1_SRAM Bank */
FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE);
}
unsigned short FSMC_RegRead(unsigned int reg)
{
return (*(unsigned short *)reg);
}
#define Banks1_SRAM1_ADD *((vu32 *)0X60000000) //数据读写地址
STM32F103VET6 FSMC只有一个bank,基地址为:0X60000000,是否需要偏移
|
-
|