STM32中断函数和主函数变量调用问题,求解!

[复制链接]
 楼主| スモモ 发表于 2019-11-28 14:20 | 显示全部楼层 |阅读模式
在main函数,exti1.c(自己写的驱动文件)和stm32f10x_it.c都要用到

uint8_t PreemptionOccured=0;
uint8_t PreemptionPriorityVale=0;
NVIC_InitTypeDef NVIC_InitStructure;这三个变量

main函数的程序:
#include "stm32f10x.h"
#include "led.h"
#include "exti1.h"

void Delay(__IO uint32_t nCount);

int main(void)

{
        
              LED_GPIO_Config();              
  EXTI1_GPIO_Config();                                 
                                
        while(1)
         {
                 if(PreemptionOccured!=0)
                 {
                         GPIO_WriteBit(GPIOA,GPIO_Pin_7,(BitAction)(1-GPIO_ReadOutputDataBit(GPIOF,GPIO_Pin_7)));
                         Delay(100);
                         GPIO_WriteBit(GPIOA,GPIO_Pin_8,(BitAction)(1-GPIO_ReadOutputDataBit(GPIOF,GPIO_Pin_8)));
                         Delay(100);
                 }
                        
}
void Delay(__IO uint32_t nCount)
{
        for(;nCount != 0; nCount--);
}

exti1.h的头文件:
#ifndef __EXTI_H1
#define __EXTI_H1
#include "stm32f10x.h"
uint8_t PreemptionOccured=0;
uint8_t PreemptionPriorityVale=0;
NVIC_InitTypeDef NVIC_InitStructure;
void EXTI1_GPIO_Config(void);
#endif

为什么我在编译的时候会报错:重复定义?
..\..\Output\ISO-STM32.axf: Error: L6200E: Symbol PreemptionOccured multiply defined (by exti1.o and main.o).
..\..\Output\ISO-STM32.axf: Error: L6200E: Symbol PreemptionPriorityVale multiply defined (by exti1.o and main.o).
..\..\Output\ISO-STM32.axf: Error: L6200E: Symbol NVIC_InitStructure multiply defined (by exti1.o and main.o).
"..\..\Output\ISO-STM32.axf" - 3 Errors, 0 Warning(s).
在主函数我并没有再次定义这三个变量:PreemptionOccured, PreemptionPriorityVale,NVIC_InitStructure这三个变量,为什么会出现报错?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

458

主题

484

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部

458

主题

484

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部