定时器中断程序

[复制链接]
923|4
 楼主| guoyt 发表于 2015-4-2 21:38 | 显示全部楼层 |阅读模式
//----------------------------------------------------------------------------
// 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.但是接上去是没有反应的。波形好像是正玄波,我希望是可以闪烁的。
hanwe 发表于 2015-4-2 21:38 | 显示全部楼层
你全局中断都没打开,哪里来的中断
M8C_EnableGInt;
yufe 发表于 2015-4-2 21:38 | 显示全部楼层
楼主大马虎啊
 楼主| guoyt 发表于 2015-4-2 21:39 | 显示全部楼层
//----------------------------------------------------------------------------
#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;
        }

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

本版积分规则

1018

主题

9067

帖子

3

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