Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1145785
  • 博文数量: 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:09:03

1.MAIN.C

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

#include "KBI.h"

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


void main(void)
{
  /* Uncomment this function call after using Device Initialization
     to use the generated code */

  MCU_init();
  /* include your code here */
  EnableInterrupts; /* enable interrupts */


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


2.KBI.C


#include <MC9S08AW60.h> /* I/O map */

void KBI_Init(void)
{
  /* ### Init_KBI init code */
  /* KBI1SC: KBIE=0 */
  KBI1SC &= (unsigned char)~0x02;
  /* KBI1PE: KBIPE7=0,KBIPE6=1,KBIPE5=1,KBIPE4=0,KBIPE3=0,KBIPE2=0,KBIPE1=0,KBIPE0=0 */
  KBI1PE = 0x60;

  /* KBI1SC: KBACK=1 */
  KBI1SC |= (unsigned char)0x04;
  /* KBI1SC: KBIE=1 */
  KBI1SC |= (unsigned char)0x02;

}

/*
** ===================================================================
** Interrupt handler : isrKBI
**
** Description :
** User interrupt service routine.
** Parameters : None
** Returns : Nothing
** ===================================================================
*/

interrupt 22 void isrKBI(void)
{
  /* Write your interrupt code here ... */

    KBI1SC_KBACK = 1; // Clears KBI interrupt flag (KBF)


  PTFD_PTFD0 = ~PTFD_PTFD0;
}

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