STM8s103P 编译出现以下结果
bad struct/union operand
是由于未宏定义芯片类型
解决方法一 在project setting里面 C Compiler 更改 Preprocessor Definitions
方法二 更改stm8s.h
将下面的
/* #define STM8S208 */ /*!< STM8S High density devices with CAN */
/* #define STM8S207 */ /*!< STM8S High density devices without CAN */
/* #define STM8AF52Ax */ /*!< STM8A High density devices with CAN */
/* #define STM8AF62Ax */ /*!< STM8A High density devices without CAN */
/* #define STM8S105 */ /*!< STM8S Medium density devices */
/* #define STM8AF626x */ /*!< STM8A Medium density devices */
/*#define STM8S103 */ /* !< STM8S Low density devices */
/* #define STM8S903 */ /*!< STM8S Low density devices */
更改为
/* #define STM8S208 */ /*!< STM8S High density devices with CAN */
/* #define STM8S207 */ /*!< STM8S High density devices without CAN */
/* #define STM8AF52Ax */ /*!< STM8A High density devices with CAN */
/* #define STM8AF62Ax */ /*!< STM8A High density devices without CAN */
/* #define STM8S105 */ /*!< STM8S Medium density devices */
/* #define STM8AF626x */ /*!< STM8A Medium density devices */
#define STM8S103 /* !< STM8S Low density devices */
/* #define STM8S903 */ /*!< STM8S Low density devices */
同时更改
注销stmflash.h 里面的
芯片falsh的大小
#if defined (STM8S103) || defined(STM8S903)
// #define FLASH_PROG_END_PHYSICAL_ADDRESS ((uint32_t)0x9FFF) /*!< Program memory: end address */
//#define FLASH_PROG_BLOCKS_NUMBER ((uint16_t)128) /*!< Program memory: total number of blocks */
// #define FLASH_DATA_START_PHYSICAL_ADDRESS ((uint32_t)0x004000) /*!< Data EEPROM memory: start address */
// #define FLASH_DATA_END_PHYSICAL_ADDRESS ((uint32_t)0x00427F) /*!< Data EEPROM memory: end address */
//#define FLASH_DATA_BLOCKS_NUMBER ((uint16_t)10) /*!< Data EEPROM memory: total number of blocks */
// #define FLASH_BLOCK_SIZE ((uint8_t)64) /*!< Number of bytes in a block (common for Program and Data memories) */
#endif /* STM8S103, STM8S903 */
两个方法不能同时使用 建议使用方法一