打印

定时器中断程序

[复制链接]
616|5
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
yinxiangh|  楼主 | 2018-6-7 13:04 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
//----------------------------------------------------------------------------
// 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.但是接上去是没有反应的。波形好像是正玄波,我希望是可以闪烁的。
沙发
chuxh| | 2018-6-7 13:07 | 只看该作者

你全局中断都没打开,哪里来的中断
M8C_EnableGInt;

使用特权

评论回复
板凳
stly| | 2018-6-7 13:12 | 只看该作者
楼主大马虎啊

使用特权

评论回复
地板
yinxiangh|  楼主 | 2018-6-7 13:14 | 只看该作者
//----------------------------------------------------------------------------
#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;
        }

}
成功点亮!很高兴。

使用特权

评论回复
5
yinxiangh|  楼主 | 2018-6-7 13:17 | 只看该作者
之前忘记设置时钟,没有开中断。看来还是有很多需要学习,没有一个好的思路!

使用特权

评论回复
6
guanjiaer| | 2018-6-26 14:47 | 只看该作者
这种时候可以断点看看各个寄存器状态

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

723

主题

7134

帖子

2

粉丝