STM8 symbol _assert_failed not defined (Debugstm8s_adc1.o )

symbol _assert_failed not defined (Debugstm8s_adc1.o )

在调试STM8的时候出现了这个问题,即函数assert_failed 未定义。查找问题,在stm8s_conf.h中对void assert_failed(u8* file, u32 line) 进行了申明,确没有文件中对该函数体进行编写,因此编译时找不到该函数而出错。因为之前没有使用库文件,全部自己调用寄存器编制的程序就没有碰到这种问题。
在头文件stm8s_conf.h中对函数有引用:
#ifdef USE_FULL_ASSERT
/**

  • @brief The assert_param macro is used for function’s parameters check.
  • @param expr: If expr is false, it calls assert_failed function
  • which reports the name of the source file and the source
  • line number of the call that failed.
  • If expr is true, it returns no value.
  • @retval : None
    /
    #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t )FILE, LINE))
    /
    Exported functions ------------------------------------------------------- /
    void assert_failed(uint8_t
    file, uint32_t line);
    #else
    #define assert_param(expr) ((void)0)
    #endif /
    USE_FULL_ASSERT */

新建一个stm8s_assert_fail.c文件,在开始时包含stm8s_conf.h,添加函数体文件如下:
#include “stm8s_conf.h”
#ifdef USE_FULL_ASSERT
/**

 

  • @brief Reports the name of the source file and the source line number
  • where the assert_param error has occurred.
  • @param file: pointer to the source file name
  • @param line: assert_param error line source number
  • @retval : None
    /
    void assert_failed(u8
    file, u32 line)
    {
    /* User can add his own implementation to report the file name and line number,
    ex: printf(“Wrong parameters value: file %s on line %drn”, file, line) */

/* Infinite loop */
while (1)
{
}
}

#endif

编译即可通过。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值