打印
[应用相关]

编译错误..\Output\BasicTim.axf: Error: L6218E: Undefined symbol time (ref...

[复制链接]
272|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
duo点|  楼主 | 2022-3-4 16:08 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
照着野火的教学视频编写了一个基本定时器的函数,其中用到的中断服务函数的子程序STM32f10x_it.c如下:

结果编译有错误..\Output\Basictim.axf: Error: L6218E: Undefined symbol time (referred from stm32f10x_it.o).

但是我在这段程序的一开头就已经定义了time变量,见下面蓝色字体。

是在不知道怎么办了,请教一下各位大神
/**
  ******************************************************************************
  * @file    Project/Template/stm32f10x_it.c
  * @author  MCD Application Team
  * @version V3.0.0
  * @date    04/06/2009
  * @Brief   Main Interrupt Service Routines.
  *          This file provides template for all exceptions handler and
  *          peripherals interrupt service routine.
  ******************************************************************************
  * @copy
  *
  * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  * TIME. AS A RESULT, STmicroELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
  * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  *
  * <h2><center>&copy; COPYRIGHT 2009 STMicroelectronics</center></h2>
  */

/* Includes ------------------------------------------------------------------*/
#include "stm32f10x_it.h"
#include "bsp_LED.h"
#include "bsp_exti.h"
#include "stm32f10x.h"
#include "bsp_usart.h"
#include "bsp_adc.h"
#include "stm32f10x_tim.h"
#include "bsp_BasicTim.h"

int8_t ucTemp;
extern uint16_t time;
extern uint16_t ADC_conversionValue;

/** @addtogroup Template_Project
  * @{
  */

/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/

/******************************************************************************/
/*            Cortex-M3 Processor Exceptions Handlers                         */
/******************************************************************************/

/**
  * @brief  This function handles NMI exception.
  * @param  None
  * @retval : None
  */
void NMI_Handler(void)
{
}

使用特权

评论回复
沙发
duo点|  楼主 | 2022-3-4 16:10 | 只看该作者
/**
  * @brief  This function handles Hard Fault exception.
  * @param  None
  * @retval : None
  */
void HardFault_Handler(void)
{
  /* Go to infinite loop when Hard Fault exception occurs */
  while (1)
  {
  }
}

/**
  * @brief  This function handles Memory Manage exception.
  * @param  None
  * @retval : None
  */
void MemManage_Handler(void)
{
  /* Go to infinite loop when Memory Manage exception occurs */
  while (1)
  {
  }
}

/**
  * @brief  This function handles Bus Fault exception.
  * @param  None
  * @retval : None
  */
void BusFault_Handler(void)
{
  /* Go to infinite loop when Bus Fault exception occurs */
  while (1)
  {
  }
}

/**
  * @brief  This function handles Usage Fault exception.
  * @param  None
  * @retval : None
  */
void UsageFault_Handler(void)
{
  /* Go to infinite loop when Usage Fault exception occurs */
  while (1)
  {
  }
}

/**
  * @brief  This function handles SVCall exception.
  * @param  None
  * @retval : None
  */
void SVC_Handler(void)
{
}

/**
  * @brief  This function handles debug Monitor exception.
  * @param  None
  * @retval : None
  */
void DebugMon_Handler(void)
{
}

/**
  * @brief  This function handles PendSVC exception.
  * @param  None
  * @retval : None
  */
void PendSV_Handler(void)
{
}

/**
  * @brief  This function handles SysTick Handler.
  * @param  None
  * @retval : None
  */
void SysTick_Handler(void)
{
}

使用特权

评论回复
板凳
duo点|  楼主 | 2022-3-4 16:12 | 只看该作者
//串口中断服务函数
//
void DEBUG_USART_IRQHandler(void)
{
        if(USART_GetITStatus(DEBUG_USARTx, USART_FLAG_RXNE)==RESET)
//也可以换成        if(USART_GetITStatus(DEBUG_USARTx, USART_IT_RXNE)!=RESET)
        {
                ucTemp = USART_ReceiveData(DEBUG_USARTx);
                USART_SendData(DEBUG_USARTx, ucTemp);
        }
}      

//一.独立模式ADC,中断服务函数读取程序
/*
void ADC_IRQHandler(void)
{
        if(ADC_GetITStatus(ADC_x, ADC_IT_EOC) == SET)
        {
                ADC_conversionValue = ADC_GetConversionValue(ADC_x);
        }
        ADC_ClearITPendingBit(ADC_x, ADC_IT_EOC);
}
*/

//基本定时器中断服务函数
void BASIC_TIM_IRQHandler(void)
{
        //判断更新中断是否发生
        if(TIM_GetITStatus(BASIC_TIM,TIM_IT_Update) != RESET)
        {
                time++;
                //清除中断标志位
                TIM_ClearITPendingBit(BASIC_TIM,TIM_IT_Update);
        }
}

/******************************************************************************/
/*                 STM32F10x Peripherals Interrupt Handlers                   */
/*  Add here the Interrupt Handler for the used peripheral(s) (PPP), for the  */
/*  available peripheral interrupt handler's name please refer to the startup */
/*  file (startup_stm32f10x_xx.s).                                            */
/******************************************************************************/

/**
  * @brief  This function handles PPP interrupt request.
  * @param  None
  * @retval : None
  */
void EXTI4_IRQHandler(void)
{
        //判断是否进入中断
        if(EXTI_GetFlagStatus(EXTI_Line4)!=RESET)
        {
        //中断服务程序
        LED_G_TOGGLE;
        }
        //执行中断服务函数完毕后,清除中断标志位
        EXTI_ClearITPendingBit(EXTI_Line4);
}

/**
  * @}
  */


/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/

使用特权

评论回复
地板
jcky001| | 2022-3-7 10:40 | 只看该作者

extern uint16_t time和uint16_t time不同的,前者只是全局声明,后者是定义。只需要再main.c中定义一个uint16_t time;即可。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

395

主题

1530

帖子

1

粉丝