各位大侠 你们好! 我在使用stm32f207vet6 外扩SRAM的时候,碰到问题啦, 外挂一个IS61WV25616,CPU和RAM之间用CPLD链接,A15~A0 使用FSMC_NL的下降沿锁存 使用MDK 仿真,在memory窗口改变数据是好的,配置如下 void FSMC_Config(void) { GPIO_InitTypeDef GPIO_InitStruct; FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure; FSMC_NORSRAMTimingInitTypeDef Timing_read, Timing_write; //-- Enable FSMC clock--------------------------------- RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE); // Configure GPIOB pins : // PB0 nc in PP_no PB1 nc in PP_no // PB2 ETH_RST out PP_down PB3 SPISCK SPI1 // PB4 SPIMISO SPI1 PB5 SPIMOSI SPI1 // PB6 nc in PP_no PB7 FSMC_NL AF PP_no // PB8 nc in PP_no PB9 FMQ AF PP_no // PB10 nc in PP_no PB11 ETH_TX_EN AF PP_no // PB12 ETH_TXD_0 AF PP_no PB13 ETH_TXD_1 AF PP_no // PB14 Device_DM AF PP_no PB15 Device_DP AF PP_no // GPIO_InitStruct.GPIO_Pin = GPIO_Pin_7;//FSMC_NL GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStruct.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStruct.GPIO_OType = GPIO_OType_PP; GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOB, &GPIO_InitStruct); GPIO_PinAFConfig(GPIOB, GPIO_PinSource7,GPIO_AF_FSMC); // Configure GPIOD pins : // PD0 FSMC_D2 AF PP_no PD1 FSMC_D3 AF PP_no // PD2 T3_ETR AF PP_no PD3 FSMC_CLK AF PP_no // PD4 FSMC_NOE AF PP_no PD5 FSMC_NWE AF PP_no // PD6 nc in PD7 FSMC_NE1 AF PP_no // PD8 FSMC_D13 AF PP_no PD9 FSMC_D14 AF PP_no // PD10 FSMC_D15 AF PP_no PD11 FSMC_A16 AF PP_no // PD12 FSMC_A17 AF PP_no PD13 A18 out PP_up // PD14 FSMC_D0 AF PP_no PD15 FSMC_D1 AF PP_no // GPIO_InitStruct.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_14 |GPIO_Pin_15; GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStruct.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStruct.GPIO_OType = GPIO_OType_PP; GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOD, &GPIO_InitStruct); GPIO_PinAFConfig(GPIOD, GPIO_PinSource0,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOD, GPIO_PinSource1,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOD, GPIO_PinSource3,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOD, GPIO_PinSource4,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOD, GPIO_PinSource5,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOD, GPIO_PinSource7,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOD, GPIO_PinSource8,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOD, GPIO_PinSource9,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOD, GPIO_PinSource10,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOD, GPIO_PinSource11,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOD, GPIO_PinSource12,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOD, GPIO_PinSource14,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOD, GPIO_PinSource15,GPIO_AF_FSMC); GPIO_InitStruct.GPIO_Pin = FSMC_Addr18;//PD13 A18 out PP_up GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStruct.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStruct.GPIO_OType = GPIO_OType_PP; GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_DOWN; GPIO_Init(GPIOD, &GPIO_InitStruct); GPIO_ResetBits(GPIOD, FSMC_Addr18); // Configure GPIOE pins : // PE0 FSMC_NBL0 AF PP_no PE1 FSMC_NBL1 AF PP_no // PE2 UPDATE out PP_down PE3 PLL_LOCKED out PP_up // PE4 PLL_RST out PP_up PE5 OUT_FAULT1 out PP_up // PE6 CS_FPGA out PP_down PE7 FSMC_D4 AF PP_no // PE8 FSMC_D5 AF PP_no PE9 FSMC_D6 AF PP_no // PE10 FSMC_D7 AF PP_no PE11 FSMC_D8 AF PP_no // PE12 FSMC_D9 AF PP_no PE13 FSMC_D10 AF PP_no // PE14 FSMC_D11 AF PP_no PE15 FSMC_D12 AF PP_no // GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|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_InitStruct.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStruct.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStruct.GPIO_OType = GPIO_OType_PP; GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOE, &GPIO_InitStruct); GPIO_PinAFConfig(GPIOE, GPIO_PinSource0,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOE, GPIO_PinSource1,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOE, GPIO_PinSource7,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOE, GPIO_PinSource8,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOE, GPIO_PinSource9,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOE, GPIO_PinSource10,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOE, GPIO_PinSource11,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOE, GPIO_PinSource12,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOE, GPIO_PinSource13,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOE, GPIO_PinSource14,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOE, GPIO_PinSource15,GPIO_AF_FSMC); //-- FSMC Configuration -------------------------------- //------------------ SRAM Bank 1 --------------------- //-- FSMC_Bank1_NORSRAM1 configuration---------------- Timing_read.FSMC_AddressSetupTime = 3; Timing_read.FSMC_AddressHoldTime = 0; Timing_read.FSMC_DataSetupTime = 3; Timing_read.FSMC_BusTurnAroundDuration =3; Timing_read.FSMC_CLKDivision = 0; Timing_read.FSMC_DataLatency = 0; Timing_read.FSMC_AccessMode = FSMC_AccessMode_C; Timing_write.FSMC_AddressSetupTime = 3; Timing_write.FSMC_AddressHoldTime = 0; Timing_write.FSMC_DataSetupTime = 3; Timing_write.FSMC_BusTurnAroundDuration = 3; Timing_write.FSMC_CLKDivision = 0; Timing_write.FSMC_DataLatency = 0; Timing_write.FSMC_AccessMode = FSMC_AccessMode_C; //-- SRAM configuration -------------------------------- // LCD configured as follow: // - Data/Address MUX = Enable // - Memory Type = SRAM // - Data Width = 16bit // - Extended Mode = Enable // - Asynchronous Wait = Disable 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_AsynchronousWait = FSMC_AsynchronousWait_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_Enable; FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable; FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &Timing_read; FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &Timing_write; FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); //---BANK 1 (of NOR/SRAM Bank 1~4) is enabled ---------- FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE); } 如果使用下面的程序,往RAM中写数据,在memory窗口看的话是乱七八糟 int main( void ) { u16 *ptr; u16 i,num; GPIO_Config(); FSMC_Config(); while(1) { ptr = (u16 *)&LCD_Disp_Buff[0]; for(i=0;i<65535;i++) { *ptr = i; //num = *ptr; ptr++; } } } 这个到底是怎么回事情?还望各位大侠不吝赐教 |
换成模式D addrset=2 addrhold=1 dataset=2 FSMC_NL上升沿锁存,还是不对,
按照我的程序,地址应该不动才对,始终应该是一个电平,
可是我在锁存出来的地址线A15~A0上面怎么看到电平波动?
这到底是怎么回事情?
//------------------ SRAM Bank 1 ---------------------
//-- FSMC_Bank1_NORSRAM1 configuration----------------
Timing_read.FSMC_AddressSetupTime = 2;
Timing_read.FSMC_AddressHoldTime = 1;
Timing_read.FSMC_DataSetupTime = 2;
Timing_read.FSMC_BusTurnAroundDuration =2;
Timing_read.FSMC_CLKDivision = 0;
Timing_read.FSMC_DataLatency = 0;
Timing_read.FSMC_AccessMode = FSMC_AccessMode_D;
Timing_write.FSMC_AddressSetupTime = 2;
Timing_write.FSMC_AddressHoldTime = 1;
Timing_write.FSMC_DataSetupTime = 2;
Timing_write.FSMC_BusTurnAroundDuration = 2;
Timing_write.FSMC_CLKDivision = 0;
Timing_write.FSMC_DataLatency = 0;
Timing_write.FSMC_AccessMode = FSMC_AccessMode_D;
//-- SRAM configuration --------------------------------
// LCD configured as follow:
// - Data/Address MUX = Enable
// - Memory Type = SRAM
// - Data Width = 16bit
// - Extended Mode = Enable
// - Asynchronous Wait = Disable
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_AsynchronousWait = FSMC_AsynchronousWait_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_Enable;
FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &Timing_read;
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &Timing_write;
FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);
//---BANK 1 (of NOR/SRAM Bank 1~4) is enabled ----------
FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE);
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_AsynchronousWait = FSMC_AsynchronousWait_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_Enable;
FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &Timing_read;
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &Timing_write;
数据线上面,好像还是没有地址项
Muxed mode - multiplexed asynchronous access to NOR Flash memory
就可以解决啦 给大家共享下
//-- FSMC_Bank1_NORSRAM1 configuration----------------
Timing_read.FSMC_AddressSetupTime = 2;
Timing_read.FSMC_AddressHoldTime = 1;
Timing_read.FSMC_DataSetupTime = 3;
Timing_read.FSMC_BusTurnAroundDuration =2;
Timing_read.FSMC_CLKDivision = 0;
Timing_read.FSMC_DataLatency = 0;
Timing_read.FSMC_AccessMode = FSMC_AccessMode_D;
Timing_write.FSMC_AddressSetupTime = 2;
Timing_write.FSMC_AddressHoldTime = 1;
Timing_write.FSMC_DataSetupTime = 3;
Timing_write.FSMC_BusTurnAroundDuration = 2;
Timing_write.FSMC_CLKDivision = 0;
Timing_write.FSMC_DataLatency = 0;
Timing_write.FSMC_AccessMode = FSMC_AccessMode_D;
//-- SRAM configuration --------------------------------
// LCD configured as follow:
// - Data/Address MUX = Enable
// - Memory Type = SRAM
// - Data Width = 16bit
// - Extended Mode = Enable
// - Asynchronous Wait = Disable
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_AsynchronousWait = FSMC_AsynchronousWait_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_WriteBurst = FSMC_WriteBurst_Disable;
FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &Timing_read;
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &Timing_write;
FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);
//---BANK 1 (of NOR/SRAM Bank 1~4) is enabled ----------
FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE);
SOP-8封装,可以提供4MB的大内存,体积很小,价格比SRAM便宜很多