A Pic Real Time Clock Ic RTC Using The ds1307 - Compress PDF
A Pic Real Time Clock Ic RTC Using The ds1307 - Compress PDF
html
[?] Subscribe
To This Site A Real Time Clock IC (DS1307) project using Custom Search
Sponsored Links...
This PIC project uses an I2C Real Time Clock IC (DS1307) and a four digit
Home seven segment display to create a standard desk clock.
Forum
Sign up for MicroZine
Problem?-Solution
''The'' Microcontroller New
Projects Showcase
LCD-Keys one port
PIC Introduction Name:
PIC Programming
E-Mail:
Programmer Types
PIC Programmer
Schematic Tool
PIC Projects
Don't worry -- your
TIPS & Techniques
e-mail address is totally
PIC Tutorials Note: If you typed DS1703 Real Time Clock to find this page you probably secure. I promise to use
C Course mis-spelled the chip type. Anyway you can find a DS1307 (RTC) Real Time it only to send you
MicroZine
Digital Downloads Clock IC project and information here.
Store
Specification Enter your first Name and prima
My Secret email address in the form above
Oscilloscopes
Contact Me Accuracy Watch crystal spec typically 20ppm And receive absolutely FREE
About Me project for:
Terms of Use Compiler Mikroelectronika C compiler V5.0.0.3 Free!
Search This Site 16F88 (retargetable to other PICs that have
"Measuring Analogue Voltag
Articles Target
Analogue input AN0). Without An ADC"
MicroBlog
Software level Medium. (Using only one pin).
Books
Resource Links Switching between i/p & o/p to read
Software notes
Site Map analogue/drive display. Using I2C routines. Instant Download:
You Can
Privacy Policy Hardware level Easy.
Get It Right Now
Special care must be taken in placing the DS1307
Hardware notes
and the crystal. Warning: This
Project version 1.00 Initial Release project could be
Removed
For battery backup lost seconds as power applied -
Project version 1.01 solved by not writing to chip at all if already at any time.
initialised.
It will NOT be
Enter your details to get the Download Link available
and get the microcontroller newsletter: indefinitely SO
To avoid
Your Name: disappointment
get it:
Project files Primary E-Mail:
Now
(Note: Your email is safe it will never be sold or rented).
You will get All the C source code and hex file.
Remember this is a project with full description
and fully debugged C Source code - and it's not
available from the main website.
Essential C Programming Course:
CLICK HERE. You can only get it through this newsletter
1 of 6 12/23/2011 12:47 PM
A PIC Real Time Clock IC (RTC) using the DS1307 http://www.best-microcontroller-projects.com/real-time-clock-ic.html
Although the PIC16F88 has a built in oscillator for a 32kHz watch crystal a There's more...
DS1307 is easier to use on a bread board. This is because you can control
the layout of the circuit more easily. You'll receive more
free and exclusive reports as
The RTC also makes the software easier as it takes care of all calendar well as site information and si
product updates.
functions; accounting for leap years etc.
The DS1307 (RTC) Real Time Clock IC (an I2C real time clock) is an 8 pin Scroll up to the form above and sign up
NOW. Don't forget it's FREE and if you
device using an I2C interface (although the data sheet does not mention
don't like it you can unsubscribe at any tim
I2C to avoid royalty payments!). It has 8 read/write registers that store the
following information:
Click Here Now to use the form above to
get your Valuable information absolutely
Address
free.
0
1
2
3 Social Bookmarking
4
5 Click & Add:
6 Blink
Del.icio.us
7
Digg
Furl
Note: Addresses 0x08 to 0xf3 are user RAM and if you use a backup
battery these are then non volatile ram i.e. they will save their contents Google
after the power is off - so you have an extra 56 bytes of ram to play with! Simpy
Spurl
Note: Address 3f is used in this project as a check to see if the clock needs Technorati
initialising and to store the upper year digit (for easier coding). Y! MyWeb
The last address 0x08 is the CONTROL address and it determines what is
generated at the SQW/OUT pin. You can control the level directly via I2C or Readers comments
set it to 1Hz, 4096Hz, 8192Hz, or 32768kHz.
"I wanted to thank
In the same way as the I2C pins you need to add a pull-up to V+ at the
you so so so much
SQW/OUT pin to see any output signal as it is an open drain output! for all the information
you have provided in
your site it's
Real Time Clock IC : Embedded control bits
SUPERB and FANTASTIC ."
There are two specific 'gotcha' type controls embedded in the addresses
- Ranish Pottath
which make using the chip slightly more complicated.
preserved otherwise the chip stops the clock. Writing zero to this bit resets - Milan
the CH bit so that the clock runs.
bursach<at>gmail.com
You have to reset the CH bit to zero to let the chip operate!
Learn PIC C Now
Real Time Clock IC DS1307 : 24/12 Hour control
Wondering
The second is the 24/12 hour control which is bit 6 of address 2. It is set
how to
high for 12 hour mode and low for 24 hour mode.
program your
The problem with these two bits is that you have to preserve them when next project
accessing the registers to write data and ignore them when reading out using C and
values for display. Its not a big problem and you can see how it's done need a great
when you look at the code. start?
2 of 6 12/23/2011 12:47 PM
A PIC Real Time Clock IC (RTC) using the DS1307 http://www.best-microcontroller-projects.com/real-time-clock-ic.html
- Matt
Using the DS1307 lets you put the crystal in the least noisy part of the matt_tr<at>
wolf359.cjb.net
board. In addition it sets the crystal load capacitance which is critical in
making the crystal oscillate at exactly 32kHz - controlling its initial error
i.e. for the specified ppm error value the load capacitance must be exact.
"I am a newbie to PIC
and I wanted to say
Note: A common way of calibrating a crystal (not in this project) is crystal how great your
pulling or changing the capacitance at one crystal pin relative to the other - site has been for me."
so load capacitance is crucial.
- Dave
The DS1307 loads the crystal with 12.7pF so you need to buy a crystal that de_scott<at>bellsouth.net
is defined to use this load capacitance. Circuit layout also affects the
capacitance at the crystal pins so you must keep the crystal as close as
possible to the chip and the tracks from crystal to chip must be short. Learn Microcontrollers
If you are doing a board layout there is good advice in the PIC 16F88
datasheet (Timer 1 section) on crystal pcb guard rings. Dallas recommends
Application note 58 which I have not read yet.
To save microcontroller pins there are four input keys which are all Very useful, uncovered,
honest and clear.
connected to a single analogue input pin. This pin also drives one of the
seven segment display LEDs so it has to be switched between input (to read Thanks so much for
the analogue voltage) and output (to drive the led). your time and works.
Regards."
Each key pulls the analogue input to a different voltage level which you can - Anon
easily read using the ADC (RA0).
If 0x20 is not found then the Real Time Clock IC is initialised to the
following values:
Address
0 Seconds
1 Minutes
2 Hours
3 Day
4 Date
5 Month
6 Year
These are all Binary Coded Decimal numbers which the Real Time Clock IC
works with. Note that the initialisation values have been chosen so you can
easily Searching
understandfor rtcthe
what DS1307?
display is showing.
3 of 6 12/23/2011 12:47 PM
A PIC Real Time Clock IC (RTC) using the DS1307 http://www.best-microcontroller-projects.com/real-time-clock-ic.html
Mode button
Pressing mode button cycles the display showing different data after each
button press. The following display sequence is followed:
1. Minutes, Secs.
2. Hours, Minutes.
3. Date, Month.
4. '20', Year.
To change a value the Edit button must be pressed. When it is the left hand
two digits are flashed on and off and the Up and Down buttons now let you
edit the value. Hitting Edit again flashes the two right hand digits and you
can change the value as before. Hitting the Edit button or the Mode button
exits the edit mode.
The clock is only stopped when editing the Minutes/Seconds display and
restarted at the end of the edit sequence or when the Mode button is hit.
This lets you set the seconds accurately but does not disturb the clock in
other modes.
You can use any PIC microcontroller that has an ADC and enough memory
to hold the program and enough pins for the display multiplexing.
You can program the PIC in circuit through the ICSP connector.
There is nothing realy difficult about the project except for placing the
DS1307 away from noise sources and decoupling it as mentioned earlier.
One point is that the multiplexed display does not use any current limit
resistors that you would normally expect. You can get away with this if the
display is on only for a very short time so that the average current out of
the pin is kept small. Turning them on for a long time would draw too much
current possibly damaging the microcontroller.
4 of 6 12/23/2011 12:47 PM
A PIC Real Time Clock IC (RTC) using the DS1307 http://www.best-microcontroller-projects.com/real-time-clock-ic.html
Project files
C Source files.
16F88_RTC_DS1307.c
I2C.c
Header files.
bit.h - bit manipulation macros
I2C.h
Output files
16F88_RTC_DS1307.hex
Description
16F88_RTC_DS1307.c
This contains the main routine and support functions for controlling the
DS1307.
init_ds1307()
read_ds1307()
write_ds1307()
edit_ds1307()
stop_ds1307()
start_ds1307()
Also in the file are analogue key reader function read_ANA_keys() and
display routines:
int2seg()
clock_display()
int2seg() - Converts a number into the required output value for PORTA to
drive the seven segment display.
Other standard routines are included for port initialisation and general
initialisation.
I2C.c
This contains the software implementation of I2C (clock stretching has not
been tested). To change the PORTs/pins alter the #define statements at the
start of I2C.c
Operation
The only other point to mention is the switching of the TRISA port for
reading the ADC at the start of the while loop. This has to set the TRIS
state correctly after the ADC read.
5 of 6 12/23/2011 12:47 PM
A PIC Real Time Clock IC (RTC) using the DS1307 http://www.best-microcontroller-projects.com/real-time-clock-ic.html
Microcontroller Newsletter
Name:
E-Mail:
Web www.best-microcontroller-projects.com
6 of 6 12/23/2011 12:47 PM