gpio_inittypedefgpio_initstructure;
usart_inittypedefusart_initstructure;
nvic_inittypedefnvic_initstruct;
rcc_ahbperiphclockcmd(rcc_ahbperiph_gpioa,enable);//使能gpioa的时钟
rcc_apb2periphclockcmd(rcc_apb2periph_usart1,enable);//使能usart的时钟
/*usart1的端口配置*/
gpio_pinafconfig(gpioa,gpio_pinsource9,gpio_af_1);//配置pa9成第二功能引脚
txgpio_pinafconfig(gpioa,gpio_pinsource10,gpio_af_1);//配置pa10成第二功能引脚rx
gpio__pingpio_pin_9|gpio_pin_10;
gpio__modegpio_mode_af;
gpio__speedgpio_speed_50mhz;
gpio__otypegpio_otype_pp;
gpio__pupdgpio_pupd_up;
gpio_init(gpioa,gpio_initstructure);/*usart1的基本是配置*/
usart__baudrate115200;//波特率
usart__wordlengthusart_wordlength_8b;
usart__stopbitsusart_stopbits_1;
usart__parityusart_parity_no;
usart__hardwareflowcontrolusart_hardwareflowcontrol_none;
usart__modeusart_mode_rx|usart_mode_tx;
usart_init(usart1,usart_initstructure);
usart_itconfig(usart1,usart_it_rxne,enable);//使能收不到网络中断
usart_cmd(usart1,enable);//使能usart1
/*usart1的nvic中断配置*/
nvic_initstruct.nvic_irqchannelusart1_irqn;
nvic_initstruct.nvic_irqchannelpriority0x02;
nvic_initstruct.nvic_irqchannelcmdenable;
nvic_init(nvic_initstruct);
调试器好象不可能指明gpio的时钟重新初始化,你全面检查下是不是gpio的时钟就没传送。诸如系统初始化gpioa时钟:
rcc_apb2periphclockcmd(rcc_apb2periph_gpioa);
其实,到目前为止要先初始化系统时钟。