RTC
Contents
[hide]RTC
RTC_Init
{{#Widget:LibTable}}Defination |
|
Input Arguments | none |
Return Value | none |
Description | This function is used to Initialize the Ds1307 RTC. |
Usage |
|
RTC_SetTime
{{#Widget:LibTable}}Defination |
|
Input Arguments |
|
Return Value | none |
Description | This function is used to update the Time(hh,mm,ss) of Ds1307 RTC. The new time is updated into the non volatile memory of Ds1307. Note: The I/P arguments should of BCD, |
Usage |
|
RTC_SetDate
{{#Widget:LibTable}}Defination |
|
Input Arguments |
|
Return Value | none |
Description | This function is used to set Date(dd,mm,yy) into the Ds1307 RTC. The new Date is updated into the non volatile memory of Ds1307. Note: The I/P arguments should of BCD. |
Usage |
|
RTC_GetTime
{{#Widget:LibTable}}Defination |
|
Input Arguments |
|
Return Value | none |
Description | This function is used to get the Time(hh,mm,ss) from Ds1307 RTC. Note: The time read from Ds1307 will be of BCD format, |
Usage |
|
RTC_GetDate
{{#Widget:LibTable}}Defination |
|
Input Arguments |
|
Return Value | none |
Description | This function is used to get the Date(d,m,y) from Ds1307 RTC. Note: The date read from Ds1307 will be of BCD format, |
Usage |
|
User Guide
- /*** Program to demonstrate the RTC library ******/
- #include "uart.h" //User defined UART library which contains the UART routines
- #include "rtc.h" //User defined library which contains the RTC(ds1307) routines
- void main()
- {
- unsigned char sec,min,hour,day,month,year;
- UART_Init(9600); /* Initialize the Uart */
- RTC_Init(); /* Initialize the RTC(ds1307)*/
- /*note: The below RTC_SetTime()/RTC_SetDate() should be called for the first time.
- Once the date and Time is set, comment the two lines ,compile and reflash the code.
- Else the date,time will be updated with same values every time the controller is reset/powered ON */
- RTC_SetTime(0x10,0x40,0x20); // 10:40:20 am
- RTC_SetDate(0x01,0x12,0x12); // 1st Dec 2012
- while(1)
- {
- RTC_GetDate(&day,&month,&year); /* Read the Date from RTC(ds1307) */
- RTC_GetTime(&hour,&min,&sec); /* Read the Time from RTC(ds1307) */
- UART_Printf("\n\rDate:%x/%x/%x Time:%x:%x:%x",day,month,year,hour,min,sec);
- }
- }