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 functionwhich reports the name of the source file and the sourceline 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 numberwhere 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
编译即可通过。