24小时热门版块排行榜    

查看: 538  |  回复: 0

人生如梦s

铜虫 (小有名气)

[求助] MC9S12XS128单片机定时器模块这个程序怎么编译一直出错,应该怎么修改

#include <hidef.h>      /* common defines and macros */
#include "derivative.h"      /* derivative-specific definitions */

#define LED0 PORTB_PB0
#define LED1 PORTB_PB1
#define LED2 PORTB_PB2

void ECTInit(void)
{
    TSCR2_TOI  = 1;  //定时器溢出中断使能
    TSCR1_TEN  = 1;  //定时器使能
   
    TIOS_IOS0 = 1; // 设置通道0为输出比较
    TIOS_IOS1 = 1; // 设置通道1为输出比较
    TC0 = 10000;
    TC1 = 20000;
    TIE_C0I = 1;  // 使能 channel 0 中断
    TIE_C1I = 1;  // 使能 channel 1 中断
   
    TCTL2_OL0 = 1;
    TCTL2_OM0 = 0;
                        
    TCTL2_OL1 = 1;
    TCTL2_OM1 = 0;
}
void main(void)
{
    ECTInit();
    DDRB = 0X07;
    EnableInterrupts;
   
    for(; { }   
}
               
interrupt VectorNumber_Vtimovf void ECT_TimerOverflow_ISR(void)
{
    TFLG2 = TFLG2_TOF_MASK;  //清零定时器溢出中断标志
    LED0 = ~ LED0;
}

interrupt VectorNumber_Vtimch0 void ECT_0_ISR(void)
{
    TFLG1 = TFLG1_C0F_MASK;   //清除通道0中断标志
    LED1 = ~ LED1;
}
interrupt VectorNumber_Vtimch1 void ECT_1_ISR(void)
{
    TFLG1 = TFLG1_C1F_MASK;    //清除通道1中断标志
    LED2 = ~ LED2;
}
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 人生如梦s 的主题更新
信息提示
请填处理意见