CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

ds1302 interface with PIC!!

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
guest
Guest







ds1302 interface with PIC!!
PostPosted: Sat Nov 05, 2005 8:24 am     Reply with quote

Hi everyone!

i want to interface the RTC chip DS1302 to PIC16f877. i know that the drivers for this chip are available in the C compiler, but i need some help with the connections between PIC and DS1302. if any one has any idea than it would be a great help!

Thanks in advance
VanHauser



Joined: 03 Oct 2005
Posts: 88
Location: Ploiesti, Romania

View user's profile Send private message

PostPosted: Sat Nov 05, 2005 9:05 am     Reply with quote

The DS1302 uses the I2C protocol in slow mode. Connect the SCL and SDA pins of the RTC to the PIC's C3 (SCL) and C4 (SDA) pins respectively. These two lines need to be pulled up to 5V by a 2K resistor each. Add the folowing line at the beginning of your code to enable the hardware I2C:
Code:
#use i2c(master, sda=PIN_C4, scl=PIN_C3, slow, force_hw)

Don't forget the ds1302_init() function. The DS1302 datasheet might also help a lot.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Nov 05, 2005 11:12 am     Reply with quote

Quote:
The DS1302 uses the I2C protocol in slow mode.

No. It uses the "3-wire" interface, which is similar to SPI, but it has
a bi-directional i/o pin. See the data sheet:
http://pdfserv.maxim-ic.com/en/ds/DS1302.pdf

Quote:

I need some help with the connections between PIC and DS1302.
If any one has any idea than it would be a great help!

Look near the start of the CCS driver file, DS1302.c.
It gives some suggested pins that you can use.
You can use those pins, or re-define them to some other pins.
Code:
#define RTC_SCLK PIN_B1
#define RTC_IO   PIN_B3
#define RTC_RST  PIN_B2
hisham.i



Joined: 22 Aug 2010
Posts: 43

View user's profile Send private message

PostPosted: Mon Mar 21, 2011 2:46 pm     Reply with quote

Why DS1302 has a driver in ccs?, i thought that i can take data in and out like max7219, but in max7219 there is no driver.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Mar 21, 2011 3:35 pm     Reply with quote

Quote:
but in max7219 there is no driver.

A "driver" is a software program that provides an easy-to-use software
interface to the hardware communications interface on a chip.

And yes, the max7219 requires a driver. Here is an example:
http://www.ccsinfo.com/forum/viewtopic.php?t=43621
Ttelmah



Joined: 11 Mar 2010
Posts: 19537

View user's profile Send private message

PostPosted: Mon Mar 21, 2011 3:52 pm     Reply with quote

and, CCS, provides _a few_ sample drivers to talk to common chips, to help you write your own. The old DS1302, is a very common chip, hence there is a supplied example. For 99% of chips though, you need to write your own (or search and see if somebody else may have done one already).

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group