Last active
July 23, 2017 00:40
-
-
Save SaheblalBagwan/97f4f3112414d3404c79ae2fb13295d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "rtc.h" | |
#include "lcd.h" | |
int main() | |
{ | |
rtc_t rtc; | |
/*Connect RS->P2.0, RW->P2.1, EN->P2.2 and data bus to P2.4 to P2.7*/ | |
LCD_SetUp(P2_0,P2_1,P2_2,P_NC,P_NC,P_NC,P_NC,P2_4,P2_5,P2_6,P2_7); | |
LCD_Init(2,16); | |
/*Connect SCL->P0.6, SDA->P0.7*/ | |
RTC_Init(); | |
rtc.hour = 0x10; // 10:40:20 am | |
rtc.min = 0x40; | |
rtc.sec = 0x00; | |
rtc.date = 0x01; //1st Jan 2016 | |
rtc.month = 0x01; | |
rtc.year = 0x16; | |
rtc.weekDay = 5; // Friday: 5th day of week considering monday as first day. | |
/*##### Set the time and Date only once. Once the Time and Date is set, comment these lines | |
and reflash the code. Else the time will be set every time the controller is reset*/ | |
RTC_SetDateTime(&rtc); // 10:40:20 am, 1st Jan 2016 | |
/* Display the Time and Date continuously */ | |
while(1) | |
{ | |
RTC_GetDateTime(&rtc); | |
LCD_GoToLine(0); | |
LCD_Printf("time:%2x:%2x:%2x \nDate:%2x/%2x/%2x",(uint16_t)rtc.hour,(uint16_t)rtc.min,(uint16_t)rtc.sec,(uint16_t)rtc.date,(uint16_t)rtc.month,(uint16_t)rtc.year); | |
} | |
return (0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment