一个简单的定时器中断程序,帮忙看看!

[复制链接]
1592|4
 楼主| wazhzlp 发表于 2012-12-21 17:19 | 显示全部楼层 |阅读模式
//----------------------------------------------------------------------------
// C main line
//----------------------------------------------------------------------------

#include <m8c.h>        // part specific constants and macros
#include "PSoCAPI.h"    // PSoC API definitions for all User Modules


void main(void)
{
         LED_1_Start();
     Timer16_1_WritePeriod(365);  
     Timer16_1_EnableInt();
     Timer16_1_Start();
while(1);
// Insert your main routine code here.
}
#pragma interrupt_handler Timer16_1_ISR
void Timer16_1_ISR()
{
    unsigned int i;
        i++;
        if(i==100)
        {
                LED_1_Invert();
                i=0;
        }

}
我在配置的时候LED_1 为port0.0.但是接上去是没有反应的。波形好像是正玄波,我希望是可以闪烁的。谢谢
傳說勝劍 发表于 2012-12-22 11:28 | 显示全部楼层
你全局中断都没打开,哪里来的中断
M8C_EnableGInt;
 楼主| wazhzlp 发表于 2012-12-22 15:33 | 显示全部楼层
//----------------------------------------------------------------------------
#include <m8c.h>        // part specific constants and macros
#include "PSoCAPI.h"    // PSoC API definitions for all User Modules


void main(void)
{
    LED_1_Start();
        M8C_EnableGInt;
    Timer16_1_Start();
    Timer16_1_EnableInt();
while(1);
// Insert your main routine code here.
}
#pragma interrupt_handler Timer16_1_ISR
void Timer16_1_ISR()
{
    unsigned int i;
        i++;
        if(i==100)
        {
                LED_1_Invert();
                i=0;
        }

}
成功点亮!很高兴。
 楼主| wazhzlp 发表于 2012-12-22 15:35 | 显示全部楼层
之前忘记设置时钟,没有开中断。看来还是有很多需要学习,没有一个好的思路!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

13

主题

51

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部