报错信息:
#error cpstm8 ..\inc\stm8s.h:75 "Please select first the target STM8S/A device used in your application (in stm8s.h file)" #error cpstm8 ..\inc\stm8s.h:2708 can't open stm8s_conf.h代码:
/* MAIN.C file
*
* Copyright (c) 2002-2005 STMicroelectronics
*/
#include "stm8s.h"
void main(void)
{
while (1);
}
#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(uint8_t* file, uint32_t 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)
{
}
}
#endif
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
原因:
- 由报错信息得知,虽然包含了stm8.h,但未开启该头文件中关于MCU类型的宏
解决方案:
- 进入stm8.h头文件,发现在未定义下述宏时,会报错
- 根据自己的STM8S型号(本文用到的是STM8S003),在stm8.h头文件中找到被注释的宏,取消注释