DXiaoFei 发表于 2013-6-4 22:54 
貌似这个达到了官方给的 STM32F207 最大GPIO速度了,不错! 以前为什么是24M ,有哪些地方做过改进?师兄把 ...
代码本质上没有什么区别,
下面是main函数代码:
/**
* @brief Main program
* @param None
* @retval None
*/
int main(void)
{
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
file (startup_stm32f2xx.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_stm32f2xx.c file
*/
/* GPIOD Periph clock enable */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
/* Configure PG6 and PG8 in output pushpull mode */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;// | GPIO_Pin_8;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOD, &GPIO_InitStructure);
/* To achieve GPIO toggling maximum frequency, the following sequence is mandatory.
You can monitor PG6 or PG8 on the scope to measure the output signal.
If you need to fine tune this frequency, you can add more GPIO set/reset
cycles to minimize more the infinite loop timing.
This code needs to be compiled with high speed optimization option. */
while (1)
{
/* Set PG6 and PG8 */
GPIOD->BSRRL = GPIO_Pin_13;// | GPIO_Pin_8;
/* Reset PG6 and PG8 */
GPIOD->BSRRH = GPIO_Pin_13;// | GPIO_Pin_8;
/* Set PG6 and PG8 */
GPIOD->BSRRL = GPIO_Pin_13;// | GPIO_Pin_8;
/* Reset PG6 and PG8 */
GPIOD->BSRRH = GPIO_Pin_13;// | GPIO_Pin_8;
/* Set PG6 and PG8 */
GPIOD->BSRRL = GPIO_Pin_13;// | GPIO_Pin_8;
/* Reset PG6 and PG8 */
GPIOD->BSRRH = GPIO_Pin_13;// | GPIO_Pin_8;
/* Set PG6 and PG8 */
GPIOD->BSRRL = GPIO_Pin_13;// | GPIO_Pin_8;
/* Reset PG6 and PG8 */
GPIOD->BSRRH = GPIO_Pin_13;// | GPIO_Pin_8;
/* Set PG6 and PG8 */
GPIOD->BSRRL = GPIO_Pin_13;// | GPIO_Pin_8;
/* Reset PG6 and PG8 */
GPIOD->BSRRH = GPIO_Pin_13;// | GPIO_Pin_8;
/* Set PG6 and PG8 */
GPIOD->BSRRL = GPIO_Pin_13;// | GPIO_Pin_8;
/* Reset PG6 and PG8 */
GPIOD->BSRRH = GPIO_Pin_13;// | GPIO_Pin_8;
/* Set PG6 and PG8 */
GPIOD->BSRRL = GPIO_Pin_13;// | GPIO_Pin_8;
/* Reset PG6 and PG8 */
GPIOD->BSRRH = GPIO_Pin_13;// | GPIO_Pin_8;
/* Set PG6 and PG8 */
GPIOD->BSRRL = GPIO_Pin_13;// | GPIO_Pin_8;
/* Reset PG6 and PG8 */
GPIOD->BSRRH = GPIO_Pin_13;// | GPIO_Pin_8;
/* Set PG6 and PG8 */
GPIOD->BSRRL = GPIO_Pin_13;// | GPIO_Pin_8;
/* Reset PG6 and PG8 */
GPIOD->BSRRH = GPIO_Pin_13;// | GPIO_Pin_8;
/* Set PG6 and PG8 */
GPIOD->BSRRL = GPIO_Pin_13;// | GPIO_Pin_8;
/* Reset PG6 and PG8 */
GPIOD->BSRRH = GPIO_Pin_13;// | GPIO_Pin_8;
}
}
|