A real-time clock is a computer clock (most often in the form of an integrated circuit) that keeps track of the current time. Although the term often refers to the devices in personal computers, servers and embedded systems, RTCs are present in almost any electronic device which needs to keep accurate time.
Code:
#include<htc.h>
#include"4 BITLCD.C"// for 4bit lcd-click here
#include"I2C.C"// for i2cprotocol-click here
#include"TIME_DATE.C"// for time_date-click here
void main()
{
TRISB=0X00;
TRISC=0X18; // SDI=SCL=1;
lcd_init();
i2c_init();
lcd_cmd(0X80,0);
lcd_str(" I2C BASED RTC ");
lcd_cmd(0X01,0);
lcd_cmd(0X80,0);
lcd_str("TIME: : :");
lcd_cmd(0XC0,0);
lcd_str("DATE: : :");
set_time(0X00,0X00); // SEC
set_time(0X01,0X01); // MIN
// set_time(0X02,0X64); // HRS & AM/PM
// set_time(0X03,0X04);
set_date(0X04,0X03); // DD
set_date(0X05,0X04); // MM
set_date(0X06,0X05); // YY
while(1)
{
// get_time(0X00,0X8B);
// get_time(0X01,0X88);
// get_time(0X02,0X85);
// get_date(0X04,0XC5);
// get_date(0X05,0XC8);
// get_date(0X06,0XCB);
}
}
For project ideas and tutorials-click here
No comments:
Post a Comment