IAR for stm8串口调试常见错误
我们在使用单片机串口调试的时候往往会出现不少的问题,下面是我们第一次做的时候基本会出现的,效果如下:
Error[Li005]: no definition for "UART2_Init" [referenced from F:\STM8\text\【2】串口\Debug\Obj\main.o]
Error[Li005]: no definition for "UART2_ITConfig" [referenced from F:\STM8\text\【2】串口\Debug\Obj\main.o]
Error[Li005]: no definition for "GPIO_Init" [referenced from F:\STM8\text\【2】串口\Debug\Obj\main.o]
Error[Li005]: no definition for "GPIO_ReadInputPin" [referenced from F:\STM8\text\【2】串口\Debug\Obj\main.o]
Error[Li005]: no definition for "UART2_SendData8" [referenced from F:\STM8\text\【2】串口\Debug\Obj\main.o]
Error while running Linker
出现这个问题的原因是因为:"void assert_failed(u8* file, u32 line);"这个函数在“stm8s_conf.h”这个文件中只是单纯的声明,他的作用来在我们在做串口调试时返回值验证出错的时候调用。因此我们需要在某个地方将这个函数进行实现。一般将他放在“main.c”进行实现。
具体解决步凑如下:
- 在main.c文件下添加如下代码:
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 %d\r\n", file, line) */
/* Infinite loop */
while (1)
{
}
}
在stm8s_conf.h 中添加 #define USE_FULL_ASSERT
此时我们大功告成啦!
会持续更新STM8系列资料,有兴趣的小伙伴加个关注呀!!!
需要资料的可以评论区留言,谢谢