Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Library for DS1302 clock (Oshonsoft Pic Basic Compiler).

DogFlu66

Member
RTC DS1302: calendar clock with 31 non-volatile memory registers for general use.
Uses 3 pins for control: CLK (SCLK), DATA (I/O) and RST.
DATA is used to receive and transmit data. For writing, an address is sent and then the data, and when reading the device, an address is sent and the reception of the data is awaited. All this is synchronized by the CLK signal and the RST pin is previously set to 1 (start signal), to indicate that communication with the RTC (abbreviation to refer to this type of device) is going to take place.

The main functions are the following:
Init_DS1302(): initializes the RTC.
Set_DS1302_24h(): set the RTC to 24-hour mode.
Set_DS1302_12h(): set the RTC to 12-hour mode.
Set_DS1302_AM_PM(bit): set AM/PM mode.
Get_DS1302_AM_PM_24h(): gets the AM/PM/24h mode from the RTC.
RTC_Set_DateTime(day, mth, year, dow, hr, min): write the date and time in the DS1302.
RTC_Get_Date(day, mth, year, dow): get the current date.
RTC_Get_Time(hr, min, sec): get the current time.
RTC_Read_NVRam(address, data): reads non-volatile ram for general purpose.
RTC_Write_NVRam(address): writes non-volatile ram for general purpose.

I attach the necessary files.
 

Attachments

  • DS1302.jpg
    DS1302.jpg
    38 KB · Views: 3
  • Test RTC DS1302.bas
    3.4 KB · Views: 1
  • _DS1302Library.bas
    14 KB · Views: 2
  • _SetUpAmicus18.bas
    2.9 KB · Views: 1
  • _Pic18F26K22Library.bas
    43.3 KB · Views: 1
Last edited:

Latest threads

New Articles From Microcontroller Tips

Back
Top