⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 time24hr.c

📁 高奇公司ICD的例子,全部能用,非常好!C语言编程
💻 C
字号:

/*********************************************************************
*                                                                    *
*                       Software License Agreement                   *
*                                                                    *
*   The software supplied herewith by Microchip Technology           *
*   Incorporated (the "Company") for its PICmicro?Microcontroller   *
*   is intended and supplied to you, the Company抯 customer, for use *
*   solely and exclusively on Microchip PICmicro Microcontroller     *
*   products. The software is owned by the Company and/or its        *
*   supplier, and is protected under applicable copyright laws. All  *
*   rights are reserved. Any use in violation of the foregoing       *
*   restrictions may subject the user to criminal sanctions under    *
*   applicable laws, as well as to civil liability for the breach of *
*   the terms and conditions of this license.                        *
*                                                                    *
*   THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION.  NO           *
*   WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING,    *
*   BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND    *
*   FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE     *
*   COMPANY SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL,  *
*   INCIDENTAL OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.  *
*                                                                    *
*********************************************************************/

/*********************************************************************
*                                                                    *
*                            412HTC                                  *
*           Hi-Tech's PICC   C Compiler Hands-on Session             *
*                                                                    *
**********************************************************************
*                                                                    *
*   Filename:       time24hr.c                                       *
*   Date:           07/18/2002                                       *
*   File Version:   1.00                                             *
*                                                                    *
*   Compiler:       Hi-Tech PICC Compiler V7.87PL1                   *
*                                                                    *
**********************************************************************
*                                                                    *
*   Files required:                                                  *
*                                                                    *
*                   pic.h        (Hi-Tech file)                      *
*                   stdio.h      (Hi-Tech file)                      *
*                   lcd.h                                            *
*                                                                    *
**********************************************************************
*                                                                    *
*   Notes:                                                           *
*                                                                    * 
*                                                                    *
*********************************************************************/

#include <pic.h>				// Processor if/def file
#include <stdio.h>				// Needed for printf
#include "lcd.h"				// Function prototypes


// ***************** Define variables and initialize *****************

unsigned char seconds = 0x00;			// Seconds variable
unsigned char minutes = 0x00;			// Minutes variable 
unsigned char hours = 0x00;			// Hours variable



/*********************************************
 *  Real Time Clock Update and Display Code  *
 *********************************************/

void Rtc_Update( void )
{
	if ( seconds < 59 )			// Is cummulative seconds < 59?
		seconds++;			// Yes, so increment seconds
	else					// else seconds => 59     
	{
		seconds = 0x00;			// Reset seconds
		if ( minutes < 59 )		// Is cummulative minutes < 59?
			minutes++;		// Yes, so updates minutes  
		else				// else minutes => 59
		{
			minutes = 0x00;		// Reset minutes
			if ( hours < 23 )	// Is cummulative hours < 23
				hours ++;	// Yes, so update hours
			else
  				hours = 0x00;	// Reset time
		}
	} 

	Home_It();				// Reset LCD Cusor to home

	printf("Time->%2d",hours);		// Print Time-> followed by hours var
	printf(":");					
	if (minutes<10) printf("0");		// If minutes <10, print leading 0
	printf("%d",minutes);			// Print minutes var
	printf(":");						
	if (seconds<10) printf("0");		// If seconds <10, print leading 0
	printf("%d",seconds);			// Print seconds var
}


/******************************
 * Timer1 initialization code *
 ******************************/

void Init_Timer1( void )
{
    T1CON = 0b00001110;				// T1CON register setup
    TMR1L = 0x00;				// Initialize Timer1 low byte: TMR1L
    ??????????;					// initialize Timer1 high byte:TMR1H
    TMR1IF = 0;					// Reset Timer1 Overflow H/W flag
    ??????????;					// Enable Timer1 Overflow interrupt:TMR1IE
    ??????????;					// Turn on Timer1 module: TMR1ON	
}

⌨️ 快捷键说明

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