打印

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

[复制链接]
285|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
スモモ|  楼主 | 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

粉丝