菜鸟用keil编译一段将外部按键作为中断控制LED灯发光熄灭的程序。
编译后提示LY-STM32.axf: Error: L6218E: Undefined symbol EXTI_ClearITpendingBit (referred from main.o).
EXTI_ClearITpendingBit 是STM32库函数中清除中断的,在stm32f10x_exti.c文件中有定义,函数原型声明在stm32f10x_exti.h文件中。
main函数中包含了#include "pbdata.h"
pbdata.h文件内容如下:
#ifndef _pbdata_H
#define _pbdata_H
#include "stm32f10x.h"
#include "stm32f10x_exti.h"
#include "misc.h"
//定义变量
extern u8 dt;
//定义函数
void delay(u32 nCount);
#endif
main函数如下:
#include "pbdata.h"
void RCC_Configuration(void);
void GPIO_Configuration(void);
void EXTI_Configuration(void);
void NVIC_Configuration(void);
void EXTI_ClearITPendingBit(uint32_t EXTI_Line);
int main(void)
{
RCC_Configuration(); //系统时钟初始化
GPIO_Configuration();//端口初始化
EXTI_Configuration(); //SET EXTRERNAL IT
NVIC_Configuration(); //
while(1);
/*while(1)
{
if(GPIO_ReadInputDataBit(GPIOC,GPIO_Pin_5)==Bit_RESET)
{
//LED 发光
GPIO_ResetBits(GPIOB,GPIO_Pin_5);
}
else
{
//LED 熄灭
GPIO_SetBits(GPIOB,GPIO_Pin_5);
}
}*/
}
void RCC_Configuration(void)
{
SystemInit();
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE);
}
void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
//LED
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_5;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
GPIO_Init(GPIOB,&GPIO_InitStructure);
//KEY
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_5;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IPU;
GPIO_Init(GPIOC,&GPIO_InitStructure);
}
void EXTI_Configuration(void)
{
EXTI_InitTypeDef EXTI_InitStructure;
EXTI_ClearITpendingBit(EXTI_Line5);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOC, GPIO_PinSource5);
EXTI_InitStructure.EXTI_Line=EXTI_Line5;
EXTI_InitStructure.EXTI_Mode=EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger=EXTI_Trigger_Rising_Falling;
EXTI_InitStructure.EXTI_LineCmd=ENABLE;
EXTI_Init(&EXTI_InitStructure);
}
void NVIC_Configuration(void)
{
NVIC_InitTypeDef NVIC_IntStructure;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
NVIC_IntStructure.NVIC_IRQChannel = EXTI9_5_IRQn;
NVIC_IntStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_IntStructure.NVIC_IRQChannelSubPriority = 2;
NVIC_IntStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_IntStructure);
}
编译完成后提示红色行部分错误Error: L6218E: Undefined symbol EXTI_ClearITpendingBit (referred from main.o).
求大神解答!先谢过!^_^
|