部分程序如下: void RCC_Configuration(void) { /* RCC复位*/ RCC_DeInit(); /* 使能外部高速晶振 */ RCC_HSEConfig(RCC_HSE_ON); /* 等待晶振稳定 */ HSEStartUpStatus = RCC_WaitForHSEStartUp(); if(HSEStartUpStatus == SUCCESS) { /* HCLK = SYSCLK 设置高速总线时钟=系统时钟*/ RCC_HCLKConfig(RCC_SYSCLK_Div1); /* PCLK2 = HCLK 设置低速总线2时钟=高速总线时钟*/ RCC_PCLK2Config(RCC_HCLK_Div1); /* PCLK1 = HCLK/2 设置低速总线1的时钟=高速时钟的二分频*/ RCC_PCLK1Config(RCC_HCLK_Div2); /* PLLCLK = 8MHz * 9 = 72 MHz */ RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9); /* Enable PLL 使能锁相环,在使能之前设置好参数*/ RCC_PLLCmd(ENABLE); /* Wait till PLL is ready 等待锁相环输出稳定*/ while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET) { } /* Select PLL as system clock source 将锁相环输出设置为系统时钟*/ RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK); /* Wait till PLL is used as system clock source 等待校验成功*/ while(RCC_GetSYSCLKSource() != 0x08) { } } } void FSMC_Configuration(void) { // RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);//使能FSMC时钟 FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure; FSMC_NORSRAMTimingInitTypeDef p; GPIO_InitTypeDef GPIO_InitStructure; /*FSMC总线使用的GPIO组时钟使能*/ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE | RCC_APB2Periph_GPIOF | RCC_APB2Periph_GPIOG | RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO, ENABLE); /*FSMC数据线FSMC_D[0:15]初始化,推挽复用输出*/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | 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); GPIO_InitStructure.GPIO_Pin = 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地址线FSMC_A[0:15]初始化,推挽复用输出*/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15; GPIO_Init(GPIOF, &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_Init(GPIOG, &GPIO_InitStructure); //以下引脚未使用: // GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13; // GPIO_Init(GPIOD, &GPIO_InitStructure); /*FSMC CLK!!!,NOE和NWE初试化,推挽复用输出*/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4 |GPIO_Pin_5; GPIO_Init(GPIOD, &GPIO_InitStructure); // /*MPU_CLK 初试化,推挽复用输出-PA8*/ // GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8; // GPIO_Init(GPIOA, &GPIO_InitStructure); /*FSMC NE1初始化,推挽复用输出*/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; GPIO_Init(GPIOD, &GPIO_InitStructure); ///*FSMC_NADV-PB7*/ // GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; // GPIO_Init(GPIOB, &GPIO_InitStructure); // GPIO_PinRemapConfig(GPIO_Remap_FSMC_NADV, DISABLE); /*!< NWAIT configuration !!!!!!*/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOD, &GPIO_InitStructure); /*FSMC NBL0和NBL1初始化,进行高低字节使能,对于CPLD不需要,推挽复用输出*/ // GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1; // GPIO_Init(GPIOE, &GPIO_InitStructure); p.FSMC_AddressSetupTime = 0x01; //地址建立时间 p.FSMC_AddressHoldTime = 0x00; //地址保持时间 p.FSMC_DataSetupTime = 0x05; //数据建立时间 p.FSMC_BusTurnAroundDuration = 0x02; //总线恢复时间 p.FSMC_CLKDivision = 0x1; //时钟分频因子 p.FSMC_DataLatency = 0x01; //数据产生时间,访问SRAM,这个参数不起作用。 p.FSMC_AccessMode = FSMC_AccessMode_A; //FSMC NOR控制器时序 FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1; //使用了FSMC的BANK1的子板块1!!!!!! FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;//禁止地址数据线复用 FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM; //存储器类型为SRAM!!!!!!(NOR) FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b; //存储器数据宽度为16位!!!!!! FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Enable; //关闭突发模式访问(Enable) FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable; FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;//等待信号优先级,只有在使能突发访问模式才有效 FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;//关闭Wrapped burst access mode,只有在使能突发访问模式才有效 FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;//等待信号设置,只有在使能突发访问模式才有效 FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable; //使能这个BANK的写操作 FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Enable;//使能/关闭等待信息设置,只在使能突发访问模式才有效(enable) FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable; //关闭Extend Mode FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable; //关闭Write Burst Mode FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p; //读操作时序参数 FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p; //写操作时序参数 FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE);//使能BANK1,SRAM1 } int main(void) { RCC_Configuration(); RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);//使能FSMC时钟 FSMC_Configuration(); 。。。 。。。 各位大神帮忙看看,rcc时钟和fsmc的配置是不是不对? |
回复:stm32读写cpld,读写失败,其中为啥fsmc_clk没有时钟?
是不是端口复用问题。。。
RE:stm32读写cpld,读写失败,其中为啥fsmc_clk没有时钟?
http://blog.csdn.net/haozi_1989/article/details/6142344
RE:stm32读写cpld,读写失败,其中为啥fsmc_clk没有时钟?
回复:stm32读写cpld,读写失败,其中为啥fsmc_clk没有时钟?
blog.csdn.net/haozi_1989/article/details/6142344
http://blog.csdn.net/haozi_1989/article/details/6142344
时钟终于出来了,是因为存储器类型不对,改成PSRAM就好了。
但是又有新问题了。读写不对了:
#define Test_1 ((u16)0xFFFF)
#define Bank1_SRAM1_ADDR ((u32)0x60000000)
#define TestRegister_ADDR (Bank1_SRAM1_ADDR + 0x0000000D)
void FSMC_CPLD_Write(u16 data, u32 WriteAddr)//¶ÔCPLD½øÐÐд²Ù×÷
{
*(u16 *) (WriteAddr) = data;
}
u16 FSMC_CPLD_Read(u32 ReadAddr)//¶ÔCPLD½øÐжÁ²Ù×÷
{
u16 pBuffer;
pBuffer = *(__IO u16*) (ReadAddr);
return pBuffer;
}
main函数里读写语句为:
FSMC_CPLD_Write(Test_1, TestRegister_ADDR);
FSMC_CPLD_Read(TestRegister_ADDR);
为什么不对了?严重怀疑写的FSMC_CPLD_Write()和FSMC_CPLD_Read()不正确!但却找不出原因……
回复:stm32读写cpld,读写失败,其中为啥fsmc_clk没有时钟?
回复:stm32读写cpld,读写失败,其中为啥fsmc_clk没有时钟?
#define CounterL_ADDR (uint32_t)(Bank1_SRAM1_ADDR + 0x00000000) //¼ÆÊýÆ÷µÍλ(16bit)
#define CounterH_ADDR (uint32_t)(Bank1_SRAM1_ADDR + 0x00000001) //¼ÆÊýÆ÷¸ßλ(16bit)
#define LatchOneL_ADDR (uint32_t)(Bank1_SRAM1_ADDR + 0x00000002) //µÚÒ»¼¶Ëø´æµÍλ(16bit)
#define LatchOneH_ADDR (uint32_t)(Bank1_SRAM1_ADDR + 0x00000003) //µÚÒ»¼¶Ëø´æ¸ßλ(16bit)
#define LatchTwoL_ADDR (uint32_t)(Bank1_SRAM1_ADDR + 0x00000004) //µÚ¶þ¼¶Ëø´æµÍλ(16bit)
#define LatchTwoH_ADDR (uint32_t)(Bank1_SRAM1_ADDR + 0x00000005) //µÚ¶þ¼¶Ëø´æ¸ßλ(16bit)
#define LatchThreeL_ADDR (uint32_t)(Bank1_SRAM1_ADDR + 0x00000006) //µÚÈý¼¶Ëø´æµÍλ(16bit)
#define LatchThreeH_ADDR (uint32_t)(Bank1_SRAM1_ADDR + 0x00000007) //µÚÈý¼¶Ëø´æ¸ßλ(16bit)
#define LatchFourL_ADDR (uint32_t)(Bank1_SRAM1_ADDR + 0x00000008) //µÚËļ¶Ëø´æµÍλ(16bit)
#define LatchFourH_ADDR (uint32_t)(Bank1_SRAM1_ADDR + 0x00000009) //µÚËļ¶Ëø´æ¸ßλ(16bit)
#define LatchFiveL_ADDR (uint32_t)(Bank1_SRAM1_ADDR + 0x0000000A) //µÚÎ弶Ëø´æµÍλ(16bit)
#define LatchFiveH_ADDR (uint32_t)(Bank1_SRAM1_ADDR + 0x0000000B) //µÚÎ弶Ëø´æ¸ßλ(16bit)
#define SimulationControl_ADDR (uint32_t)(Bank1_SRAM1_ADDR + 0x0000000C) //·ÂÕæģʽ¼Ä´æÆ÷(2bit)
#define TestRegister_ADDR (uint32_t)(Bank1_SRAM1_ADDR + 0x0000000D) //²âÊÔ¿ØÖƼĴæÆ÷(6bit)
#define IntRegister_ADDR (uint32_t)(Bank1_SRAM1_ADDR + 0x0000000E) //ÖжϿØÖƼĴæÆ÷(1bit)
#define RstRegister_ADDR (uint32_t)(Bank1_SRAM1_ADDR + 0x0000000F) //¸´Î»¿ØÖƼĴæÆ÷(16bit)
这种连续的地址允许吗???
RE:stm32读写cpld,读写失败,其中为啥fsmc_clk没有时钟?
RE:stm32读写cpld,读写失败,其中为啥fsmc_clk没有时钟?
RE:stm32读写cpld,读写失败,其中为啥fsmc_clk没有时钟?
RE:stm32读写cpld,读写失败,其中为啥fsmc_clk没有时钟?
RE:stm32读写cpld,读写失败,其中为啥fsmc_clk没有时钟?
RE:stm32读写cpld,读写失败,其中为啥fsmc_clk没有时钟?
看下这个,有专门讲FSMC
RE:stm32读写cpld,读写失败,其中为啥fsmc_clk没有时钟?