freescale

来自「Freescale 系列单片机常用模块与综合系统设计」· 代码 · 共 177 行

TXT
177
字号
/** ###################################################################
**     Filename  : Events.C
**     Project   : digital_timer
**     Processor : MC9S08JM60CLHE
**     Component : Events
**     Version   : Driver 01.02
**     Compiler  : CodeWarrior HCS08 C Compiler
**     Date/Time : 2010-1-11, 19:21
**     Abstract  :
**         This is user's event module.
**         Put your event handler code here.
**     Settings  :
**     Contents  :
**         No public methods
**
** ###################################################################*/
/* MODULE Events */


#include "Cpu.h"
#include "Events.h"

#include "Variable.h"

/* User includes (#include below this line is not maintained by Processor Expert) */

/*
** ===================================================================
**     Event       :  KEY_OnInterrupt (module Events)
**
**     Component   :  KEY [KBI]
**     Description :
**         This event is called when the active signal edge/level
**         occurs. This event is enabled only if <Interrupt
**         service/event> property is enabled.
**     Parameters  : None
**     Returns     : Nothing
** ===================================================================
*/
void KEY_OnInterrupt(void)
{
  /* Write your code here ... */
  	  __DI();	  	        //关总中断
	  clrReg8Bits(KBIPE, 0xC3);       //屏蔽键盘中断	
	  KB_valve=KB_Scan();  //扫描键值
     KB_valve=KB_Def(KB_valve);  //键值转化为定义值
     
      if(KB_valve == 'A')
      {
        sign1=1;
       } 
        
      if(KB_valve == 'B')
      {
        sign2=1;
      }  
  
	  KEY_Init();			                    //重新初始化键盘
	  setReg8Bits(KBIPE, 0xC3);     //打开键盘中断  
	  __EI();			     //开总中断
}

/*
** ===================================================================
**     Event       :  TIMER_1S_OnInterrupt (module Events)
**
**     Component   :  TIMER_1S [TimerInt]
**     Description :
**         When a timer interrupt occurs this event is called (only
**         when the component is enabled - <Enable> and the events are
**         enabled - <EnableEvent>). This event is enabled only if a
**         <interrupt service/event> is enabled.
**     Parameters  : None
**     Returns     : Nothing
** ===================================================================
*/
void TIMER_1S_OnInterrupt(void)
{
  /* Write your code here ... */
   unsigned char i;
   unsigned int  j;
   val=1;
   __DI(); ;            //关总中断
   //------------------------------
   time[6]++;             //秒数加1
   if (time[6] != 60)   //秒数未增加到60,转
   {
      goto isrTIMER1_exit;  
   }
   
   time[6] = 0; 
   time[5]++;           //秒数增加到60,清0,分钟数加1
   
   if (time[5]!=60)    //分钟数未增到60,转
   {
        goto isrTIMER1_exit; 
   }
   
   time[5] = 0; 
   time[4]++;          //分钟数增加到60,清0,小时数加1
   
   if (time[4]!=24)   //小时数未增到24,转
   {
        goto isrTIMER1_exit; 
   }
   time[4]=0; 
   time[3]++;            //时数增加到24,清0
   i=time[2];
   if( (time[2] == 1) | (time[2] == 3) | (time[2] == 5) | (time[2] == 7)
                             | (time[2] == 8) | (time[2] == 10) | (time[2] == 12) )
   {
       if(time[3] != 31) {
            goto isrTIMER1_exit;
       }
       time[3]=0; 
       time[2]++;
   }
    else if( (time[2] == 2 )| (time[2] == 4) | (time[2] == 6) | (time[2] == 9) | (time[2] == 11))
   {
       if(time[3]!=30) 
       {
            goto isrTIMER1_exit;
       }
       time[3]=0; 
       time[2]++;
   }
   else
   {
       j = time[0] * 100 + time[1];
       if(( (j % 4 == 0) && (j % 100 != 0) ) | (j % 400 == 0))
       {
         if (time[3] != 29) {
              goto isrTIMER1_exit; 
         }
         time[3]=0; 
         time[2]++;
       }
       else
       {
         if (time[3]!=28) {
              goto isrTIMER1_exit;     
         }
         time[3]=0; 
         time[2]++;
       }
   }
  
   if (time[2] != 12)
   {
      goto isrTIMER1_exit;
   }
   
   time[2] = 0; 
   time[1]++;
   
   if (time[1] != 99) {
        goto isrTIMER1_exit;
   }
   time[1] = 0; 
   time[0]++;
   isrTIMER1_exit:
  
   __EI();            //开总中断

}

/* END Events */

/*
** ###################################################################
**
**     This file was created by Processor Expert 3.07 [04.34]
**     for the Freescale HCS08 series of microcontrollers.
**
** ###################################################################
*/

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?