📄 rtc.c
字号:
//rtc.c - code recommendation for C header file
/***********************************************************************
MODULE: Real Time Clock
VERSION: 1.00
CONTAINS: Routines for controlling the Real Time Clock/System Timer
on the Philips P89LPC932
COPYRIGHT: Embedded Systems Academy, Inc. - www.esacademy.com
LICENSE: May be freely used in commercial and non-commercial code
without royalties provided this copyright notice remains
in this file and unaltered
WARNING: IF THIS FILE IS REGENERATED BY CODE ARCHITECT ANY CHANGES
MADE WILL BE LOST. WHERE POSSIBLE USE ONLY CODE ARCHITECT
TO CHANGE THE CONTENTS OF THIS FILE
GENERATED: On "Feb 24 2004" at "16:21:01" by Code Architect 2.03
***********************************************************************/
// SFR description needs to be included
#include<REG922.h>
#include "rtc.h"
#include "watchdogrtc.h"
/***********************************************************************
DESC: Initializes the Real Time Clock and starts it running
Generates an interrupt every 1.997ms
Clock source: CPU Clock at 7.3728 MHz
RETURNS: Nothing
CAUTION: Set EA to 1 to enable interrupts
************************************************************************/
void rtc_init(void)
{
// set reload value
// count frequency = clock source / 128 / RTCH,RTCL
RTCH = 0xfF;
RTCL = 0xFF;
// select CPU Clock, enable interrupt source
RTCCON = 0x62;
// initialize watchdog/real time clock interrupt
watchdogrtc_isrinit();
// start real time clock
RTCCON |= 0x01;
}
/***********************************************************************
DESC: Starts the Real Time Clock
RETURNS: Nothing
CAUTION: rtc_init must be called first
************************************************************************/
void rtc_start(void)
{
// start the real time clock
RTCCON |= 0x01;
}
/***********************************************************************
DESC: Stops the Real Time Clock
RETURNS: Nothing
CAUTION: rtc_init must be called first
************************************************************************/
void rtc_stop(void)
{
// stop the real time clock
RTCCON &= ~0x01;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -