#define DELAY5 asm("nop");asm("nop");asm("nop");asm("nop");asm("nop") #define DELAY10 DELAY5;DELAY5
void SCU_Configuration(void); void GPIO_Configuration(void); void EMI_Configuration(void); int main() { #ifdef DEBUG debug(); #endif /* Configure the system clocks */ SCU_Configuration();
/* Configure the GPIO ports */ GPIO_Configuration(); EMI_Configuration(); u16 * addr1=(u16 *)0x2C000000,* addr2=(u16 *)0x2C000000+ 0xFFFF; u16 data1=0x0,data2=0xFFFF; while(data1<data2) { *addr1 = data1; //往EMI总线上写0 *addr2 = data2; //往EMI总线上写1 *addr1 = data1; //往EMI总线上写0 *addr2 = data2; //往EMI总线上写1 *addr1 = data1; //往EMI总线上写0 *addr2 = data2; //往EMI总线上写1 } } void SCU_Configuration(void) { SCU_PFQBCCmd(ENABLE); FMI_Config(FMI_READ_WAIT_STATE_2, FMI_WRITE_WAIT_STATE_1, FMI_PWD_ENABLE, FMI_LVD_ENABLE, FMI_FREQ_HIGH); SCU_MCLKSourceConfig(SCU_MCLK_OSC); DELAY10;DELAY10;DELAY10;DELAY10;DELAY10;DELAY10; SCU_PLLCmd(DISABLE); SCU_RCLKDivisorConfig(SCU_RCLK_Div1); SCU_PCLKDivisorConfig(SCU_PCLK_Div2); SCU_HCLKDivisorConfig(SCU_HCLK_Div1); SCU_FMICLKDivisorConfig(SCU_FMICLK_Div1); SCU_EMIBCLKDivisorConfig(SCU_EMIBCLK_Div1); SCU_PLLFactorsConfig(125, 12, 2);//96M SCU_PLLCmd(ENABLE); SCU_MCLKSourceConfig(SCU_MCLK_PLL); SCU->SCR0 |=0x10;//96K SRAM SCU->SCR0 &=0xF7;
/* Enable the GPIO Clock */ SCU_APBPeriphClockConfig(__GPIO0, ENABLE); SCU_APBPeriphClockConfig(__GPIO1, ENABLE); SCU_APBPeriphClockConfig(__GPIO2, ENABLE); SCU_APBPeriphClockConfig(__GPIO3, ENABLE); SCU_APBPeriphClockConfig(__GPIO4, ENABLE); SCU_APBPeriphClockConfig(__GPIO5, ENABLE); SCU_APBPeriphClockConfig(__GPIO6, ENABLE); SCU_APBPeriphClockConfig(__GPIO7, ENABLE); SCU_APBPeriphClockConfig(__GPIO8, ENABLE); SCU_APBPeriphClockConfig(__GPIO9, ENABLE); }
void GPIO_Configuration(void) { GPIO_InitTypeDef GPIO_InitStructure; GPIO_DeInit(GPIO0); GPIO_DeInit(GPIO1); GPIO_DeInit(GPIO2); GPIO_DeInit(GPIO3); GPIO_DeInit(GPIO4); GPIO_DeInit(GPIO5); GPIO_DeInit(GPIO6); GPIO_DeInit(GPIO7); GPIO_DeInit(GPIO8); GPIO_DeInit(GPIO9); /* Gonfigure EMI */ GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All; GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Disable; GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt2; GPIO_Init (GPIO7, &GPIO_InitStructure); GPIO_Init (GPIO8, &GPIO_InitStructure); GPIO_Init (GPIO9, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Disable; GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt3; GPIO_Init (GPIO7, &GPIO_InitStructure); } /* 16位复用模式 */ void EMI_Configuration(void) { EMI_InitTypeDef EMI_InitStruct; /* Enable EMI clock */ SCU_AHBPeriphClockConfig( __EMI, ENABLE ); SCU_EMIModeConfig( SCU_EMI_MUX ); SCU_EMIALEConfig( SCU_EMIALE_LEN1,SCU_EMIALE_POLLow ); GPIO_EMIConfig( ENABLE ); EMI_DeInit(); EMI_StructInit( &EMI_InitStruct ); EMI_InitStruct.EMI_Bank_MemWidth=EMI_Width_HalfWord; EMI_InitStruct.EMI_PageModeRead_Selection=EMI_NormalMode; EMI_InitStruct.EMI_Bank_IDCY =0xf; EMI_InitStruct.EMI_Bank_WSTRD =0xf; EMI_InitStruct.EMI_Bank_WSTWR =0xf; EMI_InitStruct.EMI_Bank_WSTROEN=0xf; EMI_InitStruct.EMI_Bank_WSTWEN=0x0f; EMI_InitStruct.EMI_Bank_WSTRD =0x04; EMI_InitStruct.EMI_Bank_WSTROEN=0x03; EMI_InitStruct.EMI_Bank_WSTWR =0x04; EMI_InitStruct.EMI_Bank_WSTWEN=0x03; EMI_Init( EMI_Bank0, &EMI_InitStruct ); } |