使用IAR如何修改STM8S库

注意:以下修改在IAR for STM8 1.10 SP3下验证,库文件为IAR自带的1.1.1

1、选择CPU类型(支持STM8S系列设备)

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

根据你的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就是外设驱动选择开关,在用户函数中,只需包含此头文件即可。

比如程序中需要使用到SPI外设,则将此文件的

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

修改为:

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

如果需要在IAR中使用电容触摸按键库,需要将Stm8s_it_c中的TIM4中断屏蔽,因为触摸按键库中已经使用了这个中断

具体修改如下:

#ifdef _IAR_SYSTEMS_

//此处修改,因为采用了触摸库 
/* 
#pragma vector=0x19 
__interrupt void TIM4_UPD_OVF_IRQHandler(void) 
*/ 
#endif

即将中断屏蔽


====

http://blog.csdn.net/boliu218/article/details/6361080

你可能感兴趣的:(c,vector,File,each,compiler)