你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

查看: 1592|回复: 0

急!定时器不能中断问题!

[复制链接]

3

主题

5

回帖

0

蝴蝶豆

新手上路

最后登录
1970-1-1
发表于 2012-10-16 21:54:33 | 显示全部楼层 |阅读模式
用的是STM8L151K6
发现定时器不能中断,代码如下
extern @far @interrupt void time2_IRQHandler(void);
struct interrupt_vector const _vectab[] = {
 {0x82, (interrupt_handler_t)main}, /* reset */
 {0x82, NonHandledInterrupt}, /* trap  */
 {0x82, NonHandledInterrupt}, /* irq0  */
 {0x82, NonHandledInterrupt}, /* irq1  */
 {0x82, NonHandledInterrupt}, /* irq2  */
 {0x82, NonHandledInterrupt}, /* irq3  */
 {0x82, NonHandledInterrupt}, /* irq4  */
 {0x82, NonHandledInterrupt}, /* irq5  */
 {0x82, NonHandledInterrupt}, /* irq6  */
 {0x82, NonHandledInterrupt}, /* irq7  */
 {0x82, NonHandledInterrupt}, /* irq8  */
 {0x82, NonHandledInterrupt}, /* irq9  */
 {0x82, NonHandledInterrupt}, /* irq10 */
 {0x82, NonHandledInterrupt}, /* irq11 */
 {0x82, NonHandledInterrupt}, /* irq12 */
 {0x82, time2_IRQHandler}, /* irq13 */
 {0x82, NonHandledInterrupt}, /* irq14 */
 {0x82, NonHandledInterrupt}, /* irq15 */
 {0x82, NonHandledInterrupt}, /* irq16 */
 {0x82, NonHandledInterrupt}, /* irq17 */
 {0x82, NonHandledInterrupt}, /* irq18 */
 {0x82, NonHandledInterrupt}, /* irq19 */
 {0x82, NonHandledInterrupt}, /* irq20 */
 {0x82, NonHandledInterrupt}, /* irq21 */
 {0x82, NonHandledInterrupt}, /* irq22 */
 {0x82, NonHandledInterrupt}, /* irq23 */
 {0x82, NonHandledInterrupt}, /* irq24 */
 {0x82, NonHandledInterrupt}, /* irq25 */
 {0x82, NonHandledInterrupt}, /* irq26 */
 {0x82, NonHandledInterrupt}, /* irq27 */
 {0x82, NonHandledInterrupt}, /* irq28 */
 {0x82, NonHandledInterrupt}, /* irq29 */
};
@far @interrupt void time2_IRQHandler(void)
{
  RCRST_1;
   TIM2_SR1 &= ~0x01;    //清除中断标记
  RTC_FLOW_FLAG = 1; 
  
  return;
}
void sys_ini(void)

    unsigned char i;
    CLK_ICKCR |= 0X01;    //打开内部HSI时钟
   while(!(CLK_ICKCR & 0X02));    //等待内部时钟稳定
   CLK_CKDIVR = 0x12;    //0x1a;    //
   CLK_CSSR = 0X00;
   TIM2_IER = 0X00;    //先禁止中断
   TIM2_EGR = 0X01;    //允许产生更新事件
   TIM2_PSCR = 0X04;    
   TIM2_ARRH = RTCH_SET;    //设置定时
   TIM2_ARRL = RTCL_SET;  
   TIM2_CNTRH = RTCH_SET;
   TIM2_CNTRL = RTCL_SET;
   TIM2_CR1 |= 0X81;    //开启定时器时间初始值  
   TIM2_IER |= 0X01;    //允许更新中断
  
   _asm("rim");    //允许CPU全局中断
}
 
已经搞了一个星期了,真的要崩溃了。是我的技术太菜了吗?确实是刚接触STM。哎!请高手指点一下啊
extern @far @interrupt void time2_IRQHandler(void);
有声明的,这个声明在STM_INTERRUUT_VECTOR.C中
会不会是单片机质量有问题或者烧录器有问题啊,用的是ST-LINK/V2
回复

使用道具 举报

关于意法半导体
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
招聘信息
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
关注我们
st-img 微信公众号
st-img 手机版