STM32F030系列注意事项

1,奇怪问题:串口能接收,但是进不了串口中断处理函数;其他中断能进入各自中断函数,向量表没问题(已经在IAP—boot中搬移到内存0x20000000中size 0xB4);

 处理办法:1,屏蔽其他处理代码,只留串口相关代码;查看外设时钟配置(正确);认真检查串口管脚配置,好像没问题;NVIC优先级初始化配置正确;

      2,。。。想死的心都有了,逐行看代码吧。。。。

      3,发现串口管脚配置错误:

USART_DeInit(USART1);
// Configure USART1_Tx as alternate function push-pull
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType=GPIO_OType_PP;
GPIO_Init(GPIOA, &GPIO_InitStructure);

// Configure USART1_Rx as input floating (作浮空输入应该是10xx系列配置,不适合030)
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//GPIO_Mode_IN **********************就是这里错误(已改正!)

GPIO_InitStructure.GPIO_PuPd=GPIO_PuPd_UP;

GPIO_Init(GPIOA, &GPIO_InitStructure);

GPIO_PinAFConfig(GPIOA,GPIO_PinSource9,GPIO_AF_1);
GPIO_PinAFConfig(GPIOA,GPIO_PinSource10,GPIO_AF_1);

posted @ 2016-02-26 16:46  小温点秋香  阅读(962)  评论(0编辑  收藏  举报