Real Time Clock
The Real Time Clock is use for storing and updating the time.This powered by a battery when there is no power supply keeping the clock up-to-date.The RTC Chip also has a tiny RAM in it of 64Bytes known as CMOS.The RTC Chip is capable of holding multiple frequency.This chip has a pre-programmed frequency 32.768 KHz. It is possible to change this value but setting an improper value may affect your systems accuracy.32.768 is a very accurate frequency.The port used for the RTC is same for the CMOS too.The port 0x70 is known as the address port and 0x71 as the data port.This Real Time Clock can be used as a timer through IRQ 8.
Examples:
Reading the time and date from the RTC Chip
int seconds,minutes,hours,day,month,year;
void get_time_rtc()
{
interrupt_disable();
seconds = read_cmos(0x0); minutes = read_cmos(0x2);
hours = read_cmos(0x4);
day = read_cmos(0x7);
month = read_cmos(0x8);
year =read_cmos(0x9);
interrupt_enable();
if(CMOSDATA_BIN_OR_BCD == BCD)
{
seconds = BCD2BIN(seconds);
minutes = BCD2BIN(minutes);
hours = BCD2BIN(hours);
day = BCD2BIN(day);
month = BCD2BIN(month);
year = BCD2BIN(year);
}
}
===============================================================================================
Links:
CMOS Ram
Examples:
Reading the time and date from the RTC Chip
int seconds,minutes,hours,day,month,year;
void get_time_rtc()
{
interrupt_disable();
seconds = read_cmos(0x0); minutes = read_cmos(0x2);
hours = read_cmos(0x4);
day = read_cmos(0x7);
month = read_cmos(0x8);
year =read_cmos(0x9);
interrupt_enable();
if(CMOSDATA_BIN_OR_BCD == BCD)
{
seconds = BCD2BIN(seconds);
minutes = BCD2BIN(minutes);
hours = BCD2BIN(hours);
day = BCD2BIN(day);
month = BCD2BIN(month);
year = BCD2BIN(year);
}
}
===============================================================================================
Links:
CMOS Ram