新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > 使用IAR如何修改STM8S庫(一)

使用IAR如何修改STM8S庫(一)

作者: 時間:2016-11-24 來源:網(wǎng)絡 收藏
注意:以下修改在IAR for STM8 1.10 SP3下驗證,庫文件為IAR自帶的1.1.1

1、選擇CPU類型(支持STM8S系列設備)

本文引用地址:http://www.2s4d.com/article/201611/320848.htm

stm8s.h

...

/* Uncomment the line below according to the target STM8S device used in your

application.

Tip: To avoid modifying this file each time you need to switch between these

devices, you can define the device in your toolchain compiler preprocessor. */

#if !defined (STM8S208) && !defined (STM8S207) && !defined (STM8S105) && !defined (STM8S103) && !defined (STM8S903)

#define STM8S208

/* #define STM8S207 */

/* #define STM8S105 */

/* #define STM8S103 */

/* #define STM8S903 */

#endif

根據(jù)你的CPU類型選擇宏定義,比如我這里用的是105系列,則修改為:

/* #define STM8S208 */

/* #define STM8S207 */

#define STM8S105

/* #define STM8S103 */

/* #define STM8S903 */

選擇好CPU類型后,還需查看選擇的類型中哪些外設是包含的哪些外設沒有包含,將沒有包含的外設驅動c文件在工程中去掉

如105系列沒有adc2、can、uart1、uart3

2、修改stm8s_conf.h文件

選擇好CPU類型后,接下來就是選擇要使用的外設了,stm8s_conf.h就是外設驅動選擇開關,在用戶函數(shù)中,只需包含此頭文件即可。

比如程序中需要使用到SPI外設,則將此文件的

/************************************* SPI ************************************/
/* #define _SPI (1) */

修改為:

/************************************* SPI ************************************/
#define _SPI (1)



關鍵詞: IARSTM8S

評論


技術專區(qū)

關閉