GPIO_InitTypeDef GPIO_InitStructure; TIM_InitTypeDef TIM_InitStructure; UART_InitTypeDef UART_InitStructure; #if 1 /* SYSTEM CLOCK Configuration ------------------------------------------------*/ //CPU = 25MHZ SCU_MCLKSourceConfig(SCU_MCLK_OSC); SCU_RCLKDivisorConfig(SCU_RCLK_Div1024);//执这里出错 //PLL = 96MHz SCU_PLLCmd(DISABLE); SCU_PLLFactorsConfig(0xC0,0x19,0x2); SCU_PLLCmd(ENABLE); //CPU = 96MHZ SCU_MCLKSourceConfig(SCU_MCLK_PLL); #endif
/* SYSTEM CLOCK Configuration ------------------------------------------------*/ SCU_AHBPeriphClockConfig(__VIC, ENABLE); VIC_DeInit(); /* VIC configuration */ VIC_Config(TIM0_ITLine, VIC_IRQ, TIM0_ITLine); VIC_ITCmd(TIM0_ITLine, ENABLE); VIC_Config(UART0_ITLine, VIC_IRQ, UART0_ITLine); VIC_ITCmd(UART0_ITLine, ENABLE); /* TIMER Configuration -------------------------------------------------------*/ /* TIM0 Deinitialization */ SCU_APBPeriphClockConfig(__TIM01, ENABLE); /* Enable the clock for TIM0 and TIM1 */ TIM_DeInit(TIM0); /* TIM0 Structure Initialization */ TIM_StructInit(&TIM_InitStructure); TIM_InitStructure.TIM_Mode = TIM_OCM_CHANNEL_1; TIM_InitStructure.TIM_Clock_Source = TIM_CLK_APB; TIM_InitStructure.TIM_Prescaler = 0; TIM_InitStructure.TIM_Pulse_Level_1 = TIM_HIGH; TIM_InitStructure.TIM_Period_Level = TIM_LOW; TIM_InitStructure.TIM_Pulse_Length_1 = 0x200; TIM_InitStructure.TIM_Full_Period = 0x404; TIM_InitStructure.TIM_OC1_Modes=TIM_TIMING; TIM_Init (TIM0, &TIM_InitStructure); /* Clear TIM0 ISR registers */ TIM_ClearFlag(TIM0, TIM_FLAG_OC1| TIM_FLAG_OC2| TIM_FLAG_TO|TIM_FLAG_IC1|TIM_FLAG_IC2); /* Enable TIM0 IC1 interrupt */ TIM_ITConfig(TIM0, TIM_IT_OC1, ENABLE); /* Start the counter of TIM0 */ TIM_CounterCmd(TIM0, TIM_START); /* GPIO Configuration --------------------------------------------------------*/ SCU_APBPeriphClockConfig(__GPIO3, ENABLE); /* Enable the clock for GPIO3 */ GPIO_DeInit(GPIO3); /* GPIO3 Deinitialization */ GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;//GPIO_Pin_0 |GPIO_Pin_4; GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; GPIO_InitStructure.GPIO_Alternate=GPIO_OutputAlt1; GPIO_Init (GPIO3, &GPIO_InitStructure);
/*Gonfigure UART0_Tx pin GPIO3.4*/ GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt3 ; GPIO_Init (GPIO3, &GPIO_InitStructure); GPIO_DeInit(GPIO5); /*Gonfigure UART0_Rx pin GPIO5.1*/ GPIO_InitStructure.GPIO_Direction = GPIO_PinInput; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Enable; GPIO_Init (GPIO5, &GPIO_InitStructure);
/* UART Configuration --------------------------------------------------------*/ SCU_APBPeriphClockConfig(__UART0, ENABLE); UART_InitStructure.UART_WordLength = UART_WordLength_8D; UART_InitStructure.UART_StopBits = UART_StopBits_1; UART_InitStructure.UART_Parity = UART_Parity_No ; UART_InitStructure.UART_BaudRate = 115200; UART_InitStructure.UART_HardwareFlowControl = UART_HardwareFlowControl_None; UART_InitStructure.UART_Mode = UART_Mode_Tx_Rx; UART_InitStructure.UART_FIFO = UART_FIFO_Enable; UART_InitStructure.UART_TxFIFOLevel = UART_FIFOLevel_1_2; /* FIFO size 16 bytes, FIFO level 8 bytes */ UART_InitStructure.UART_RxFIFOLevel = UART_FIFOLevel_1_2; /* FIFO size 16 bytes, FIFO level 8 bytes */ UART_DeInit(UART0); UART_Init(UART0, &UART_InitStructure); /* Clear UART flags*/ UART_ClearFlag(UART0); /* Enable UART interrupt */ UART_ITConfig(UART0, UART_IT_Receive, ENABLE); /* Enable the UART0 */ UART_Cmd(UART0, ENABLE); }
为什么会这样,请各位大侠帮我看看,究竟是怎么回事?有什么办法解决!谢谢各位了! |