首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

求助:想写一个RTI 中断的程序

什么芯片?可以参看CodeWarrior自带的示例程序。
海纳百川  有容乃大
#include
#include
#pragma LINK_INFO DERIVATIVE ""


unsigned char RTIs1_Cnt = 0;

void MCU_init(void)
{
PORTB = 0xFF;
DDRB = 0x03;

CRGINT &= ~18;
RDRIV &= ~147;
INTCR &= ~64;
RTICTL = 127;

RTIs1_Cnt = 0;
CRGFLG = 128;
CRGINT = 128;
}


void main(void) {
/* put your own code here */

MCU_init();

EnableInterrupts;

for(;;) {} /* wait forever */
/* please make sure that you never leave this function */
}


#pragma CODE_SEG __NEAR_SEG NON_BANKED
void interrupt 7 RTIs1_Interrupt(void)
{
PORTB_BIT0 ^= 1;
RTIs1_Cnt++; /* Increment SW counter CntVar */
if(RTIs1_Cnt == 160)
{ /* Is it now the period time? */
RTIs1_Cnt = 0; /* Reset SW counter Cnt */
PORTB_BIT1 ^= 1;
/* Warning: This bean is not used by any other bean! */
}
CRGFLG = 128; /* Reset interrupt request flag */
}
海纳百川  有容乃大
请参考文档S12CRGV4.pdf。
海纳百川  有容乃大
返回列表