<div class="t_msgfontfix">[table] [tr] [td]本人刚接触STM32,希望大侠们指教,谢谢! 按键外部中断进不去,用的3.4的固件库,按键为下降沿中断方式,接在mcu的PC13口,程序实现功能为LED起初循环点亮,按键按下时,执行中断程序,其中LED由PF口控制,如下 /******************************************************************************* * File Name : main.c * Author : Nanjing * Date First Issued : 04/12/2011 * Description : Main program body ********************************************************************************/ /* Includes ------------------------------------------------------------------*/ #include "stm32f10x.h" #include "main.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ static __IO uint32_t TimingDelay; NVIC_InitTypeDef NVIC_InitStructure; GPIO_InitTypeDef GPIO_InitStructure; EXTI_InitTypeDef EXTI_InitStructure; ErrorStatus HSEStartUpStatus; /* Private function prototypes -----------------------------------------------*/ void Delay(__IO uint32_t nTime); void RCC_Configuration(void) ; void SysTick_Configuration(void); void GPIO_Configuration(void); void EXTI_Configuration(void); /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : main * Description : Main program. * Input : None * Output : None * Return : None *******************************************************************************/ int main(void) { #ifdef DEBUG debug() ; #endif /* Setup SysTick Timer for 1 msec interrupts */ /* Configure the system clocks */ RCC_Configuration(); SysTick_Configuration(); /* Configure the GPIO ports */ GPIO_Configuration(); EXTI_Configuration(); /***循环点亮LED****/ for(;;) { GPIOF->ODR=0xfffffc4f; /* Insert 50 ms delay */ Delay(500); GPIOF->ODR=0xfffffc8f; /* Insert 50 ms delay */ Delay(500); GPIOF->ODR=0xfffffd0f; /* Insert 50 ms delay */ Delay(500); GPIOF->ODR=0xfffffe0f; /* Insert 50 ms delay */ Delay(500); } } /** * @brief Inserts a delay time. * @param nTime: specifies the delay time length, in milliseconds. * @retval None */ void SysTick_Configuration(void) { /* Setup SysTick Timer for 100 msec interrupts */ if (SysTick_Config((SystemCoreClock) / 1000)) // 1/1000s=1ms { /* Capture error */ while (1); } NVIC_SetPriority(SysTick_IRQn, 0x0); } void Delay(__IO uint32_t nTime) //定义nTime为可读可写的int { TimingDelay = nTime; while(TimingDelay != 0); } /** * @brief Decrements the TimingDelay variable. * @param None * @retval None */ void TimingDelay_Decrement(void) { if (TimingDelay != 0x00) { TimingDelay--; } } /******************************************************************************* * Function Name : GPIO_Configuration * Description : Configures the different GPIO ports. * Input : None * Output : None * Return : None *******************************************************************************/ void NVIC_Configuration(void) { #ifdef VECT_TAB_RAM NVIC_SetVectorTable(NVIC_VectTab_RAM,0x0); #else NVIC_SetVectorTable(NVIC_VectTab_FLASH,0x0); #endif NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); NVIC_InitStructure.NVIC_IRQChannel=EXTI15_10_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=0; NVIC_InitStructure.NVIC_IRQChannelSubPriority=0; NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE; NVIC_Init(&NVIC_InitStructure); } void RCC_Configuration(void) { //必须开时钟才能 使用起来 相应IO RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOF|RCC_APB2Periph_GPIOC|RCC_APB2Periph_AFIO,ENABLE); } /******************************************************************************* * Function Name : GPIO_Configuration * Description : Configures the different GPIO ports. * Input : None * Output : None * Return : None *******************************************************************************/ void GPIO_Configuration(void) { /*配置PF口为输出推免,速度50MHz*/ GPIO_InitStructure.GPIO_Pin=GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9; GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP; GPIO_Init(GPIOF,&GPIO_InitStructure); /* Configure PC13 as input floating (EXTI Line13) */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOC, &GPIO_InitStructure); } void EXTI_Configuration(void) { /* Configure EXTI Line13 to generate an interrupt on falling edge */ GPIO_EXTILineConfig(GPIO_PortSourceGPIOC,GPIO_PinSource13); //选择中断管脚PC13 EXTI_InitStructure.EXTI_Line=EXTI_Line13; EXTI_InitStructure.EXTI_Mode=EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger=EXTI_Trigger_Falling; EXTI_InitStructure.EXTI_LineCmd=ENABLE; EXTI_Init(&EXTI_InitStructure); } /******************************************************************************* * Function Name : Delay * Description : Inserts a delay time. * Input : nCount: specifies the delay time length. * Output : None * Return : None *******************************************************************************/ #ifdef DEBUG /*描述:当程序出错时,返回出错的文件名及在源程序中的行号 输入:—file:指向文件名的指针 —line:在源程序中的行号 输出:无 返回:无 */ void assert_failed(u8*file,u32 line) { while(1) {} } #endif 以下为用到的中断程序: void SysTick_Handler(void) { TimingDelay_Decrement(); } void EXTI15_10_IRQHandler(void) { int i; if(EXTI_GetITStatus(EXTI_Line13)!=RESET) { //二极管全部熄灭 for(i=0;iODR=0xfffffc3f; // /* Insert 50 ms delay */ // Delay(500); //二极管全部点亮 for(i=0;iODR=0xffffffff; // /* Insert 50 ms delay */ // Delay(500); for(i=0;i |
RE:【求助】按键外部中断进不去,用的3.4的库
RE:【求助】按键外部中断进不去,用的3.4的库
RE:【求助】按键外部中断进不去,用的3.4的库
RE:【求助】按键外部中断进不去,用的3.4的库
2.需要加入EXTI_GenerateSWInterrupt(EXTI_Line13);//设置PC13口为外部中断输入线13产生一个软件中断
回复:【求助】按键外部中断进不去,用的3.4的库
RE:【求助】按键外部中断进不去,用的3.4的库
RE:【求助】按键外部中断进不去,用的3.4的库
回复:【求助】按键外部中断进不去,用的3.4的库
行了,谢谢楼上几位
请问你是怎么解决的啊,我也出现了这个问题
回复:【求助】按键外部中断进不去,用的3.4的库
基于固件库的工程调用不了stm32f10x.h里面的定义,不知为何。。。