在开发板USE_STM3210E_EVAL上调试RTC例程调用GPIO_Configuration函数的时候 void GPIO_Configuration(void) { GPIO_InitTypeDef GPIO_InitStructure;
/* Configure GPIO_LED pin 6 as Output push-pull */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIO_LED, &GPIO_InitStructure);
/* Configure USART1 Tx (PA.09) as alternate function push-pull */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOA, &GPIO_InitStructure);
/* Configure USART1 Rx (PA.10) as input floating */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOA, &GPIO_InitStructure); } 如果把它变成下面的样子 void GPIO_Configuration(void) { GPIO_InitTypeDef GPIO_InitStructure;
/* Configure GPIO_LED pin 6 as Output push-pull */ //GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //GPIO_Init(GPIO_LED, &GPIO_InitStructure);
/* Configure USART1 Tx (PA.09) as alternate function push-pull */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOA, &GPIO_InitStructure);
/* Configure USART1 Rx (PA.10) as input floating */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOA, &GPIO_InitStructure); } 它就不能跟PC通信了,我的main()函数是这样的: int main(void) { #ifdef DEBUG debug(); #endif
/* System Clocks Configuration */ RCC_Configuration();
/* NVIC configuration */ NVIC_Configuration();
/* Configure the GPIOs */ GPIO_Configuration();
/* Configure the USART1 */ USART_Configuration(); printf("printf test..."); while(1);
} 刚开始我以为是中断影响,但是我把中断配置屏蔽了,如下: void NVIC_Configuration(void) { NVIC_InitTypeDef NVIC_InitStructure;
#ifdef VECT_TAB_RAM /* Set the Vector Table base location at 0x20000000 */ NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0); #else /* VECT_TAB_FLASH */ /* Set the Vector Table base location at 0x08000000 */ NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0); #endif
/* Configure one bit for preemption priority */ NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
/* Enable the RTC Interrupt */ //NVIC_InitStructure.NVIC_IRQChannel = RTC_IRQChannel; //NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; //NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; //NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //NVIC_Init(&NVIC_InitStructure); } 评估板还是不能与PC通信,但是如果把GPIO初始化程序改成如下: void GPIO_Configuration(void) { GPIO_InitTypeDef GPIO_InitStructure;
/* Configure GPIO_LED pin 6 as Output push-pull */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIO_LED, &GPIO_InitStructure);
/* Configure USART1 Tx (PA.09) as alternate function push-pull */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOA, &GPIO_InitStructure);
/* Configure USART1 Rx (PA.10) as input floating */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOA, &GPIO_InitStructure); } 就可以通信,感觉好像USART1与PC通信,一定要设置管脚PF0.6,但是我查看了规格书,PF0.6并没有USART功能啊,程序里面除了RTC中断也没有别的地方调用PF0.6端口的,不知道是为什么? 我的环境是USE_STM3210E_EVAL评估板,keil3.24
|