freescale

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

TXT
105
字号
/** ###################################################################
**     Filename  : digital_timer.C
**     Project   : digital_timer
**     Processor : MC9S08JM60CLHE
**     Version   : Driver 01.11
**     Compiler  : CodeWarrior HCS08 C Compiler
**     Date/Time : 2010-1-11, 19:21
**     Abstract  :
**         Main module.
**         This module contains user's application code.
**     Settings  :
**     Contents  :
**         No public methods
**
** ###################################################################*/
/* MODULE digital_timer */


/* Including needed modules to compile this module/procedure */
#include "Cpu.h"
#include "Events.h"
#include "buzzer.h"
#include "LCD_CONTROL.h"
#include "LCD_DATA.h"
#include "KEY_LINE.h"
#include "KEY.h"
#include "TIMER_1S.h"
/* Include shared modules, which are used for whole project */
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"

#include  "Variable.h"
#include  "Time.h"
#include  "LCD1602.h"

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

void main(void)
{
  /* Write your local variable definition here */
  Uchar h,l;
  val = 0;
  sign1 = 0;
  sign2 = 0;
  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
  /*** End of Processor Expert internal initialization.                    ***/
  Init_Time();                                   //初始化时间
  Time_Conver();
  Lcd_Show((Uchar *)time1);
  /* Write your code here */
  for( ; ;) {
    h=0;
	  for(l = 0; l<7; l++)                      //闹钟
      {
         if(time[l] != time2[l]) 
          break;
         h++;
         if(h == 7)
         {
           Alarm_Time(30);
         }
      }
	  if((time[6] == 0) && (time[5] == 0) && (time[4] == 0))//整点报时
      {
         buzzer_PutVal(1);
         WaitNms(100);
         buzzer_PutVal(0);
         WaitNms(100);
      }
      if(sign1 == 1)
      {
        clrReg8Bits(KBIPE, 0xC3);       //屏蔽键盘中断
         Set_Time();                              //设置时间
         sign1=0;
         setReg8Bits(KBIPE, 0xC3);     //打开键盘中断  
      }
      if(sign2 == 1)
      {
        clrReg8Bits(KBIPE, 0xC3);       //屏蔽键盘中断
        sign2=0;
        Set_Alarm_Clock();                 //设置闹钟时间
        setReg8Bits(KBIPE, 0xC3);      //打开键盘中断  
      }
	   if (val == 1)                                //时间溢出中断发生
	   {
	      Time_Conver();
 	      Lcd_Show((unsigned char *)time1);//每一秒更新
 	      val=0;
     } 
  }
}

/* END digital_timer */
/*
** ###################################################################
**
**     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 + -
显示快捷键?