使用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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值