Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1142434
  • 博文数量: 139
  • 博客积分: 2510
  • 博客等级: 少校
  • 技术积分: 1712
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-13 23:10
个人简介

每天进步一点点。

文章分类

全部博文(139)

文章存档

2015年(3)

2014年(11)

2013年(25)

2011年(1)

2009年(3)

2008年(29)

2007年(45)

2006年(22)

分类: C/C++

2008-10-29 10:14:59

1.main.c



#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */

#include "RTI.h"

byte i=1;

void MCU_init(void) /* Device initialization function declaration */
{
  RTI_Init();
  /* ### Init_GPIO init code */
  /* PTFDD: PTFDD0=1 */
  PTFDD |= (unsigned char)0x03;
}

void main(void)
{

  /* Uncomment this function call after using Device Initialization
     to use the generated code */

  MCU_init();

  EnableInterrupts; /* enable interrupts */

  /* include your code here */



  for(;;)
  {
    __RESET_WATCHDOG(); /* feeds the dog */
    
  } /* loop forever */
  /* please make sure that you never leave this function */
}


2.RTI.C


#include <MC9S08AW60.h>

extern byte i;
void RTI_Init(void)
{
  /* SRTISC: RTIF=0,RTIACK=0,RTICLKS=0,RTIE=1,??=0,RTIS2=1,RTIS1=1,RTIS0=1 */
  SRTISC = 0x17; /* Run RTI (select clock source, set frequncy and enable interrupt )*/
}


interrupt 25 void isrRTI(void)
{
  SRTISC_RTIACK = 1; /* Reset real-time interrupt request flag */
  PTFD_PTFD0 = ~PTFD_PTFD0;
  i++;
  if(i==10)
  {
    i = 1;
    PTFD_PTFD1 = ~PTFD_PTFD1;
  }
}

阅读(2490) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~