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 support@ccsinfo.com

make i2c ds1307 realtime clock work

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



Joined: 17 Nov 2011
Posts: 187

View user's profile Send private message Send e-mail

make i2c ds1307 realtime clock work
PostPosted: Thu Nov 17, 2011 10:55 am     Reply with quote

Hi,
How to make DS1307 real time clock work...
How to set time and how to get time?
Any example program for ccs c-compiler?
I know you guys have done it before and I'm happy if
you tell me how ... for sure I can spend lot of time to do it myself.
( I'm electronic hobbyist ... no business)

I know those functions i2c I read from ccs c manual
but how to make them really work ? Question

Laughing
brgds
-arto-
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Nov 17, 2011 12:57 pm     Reply with quote

There is a ds1307 driver in the CCS Code Library forum. Use it.

There is a schematic of the ds1307 circuit in the ds1307 data sheet.
Use it. Make sure you have the 4.7K pullup resistors, and make sure
you have the 3v lithium battery on the Vbat pin. All of this is shown
in the schematic.
artohautala



Joined: 17 Nov 2011
Posts: 187

View user's profile Send private message Send e-mail

PostPosted: Tue Nov 29, 2011 10:17 am     Reply with quote

PCM programmer wrote:
There is a ds1307 driver in the CCS Code Library forum. Use it.

There is a schematic of the ds1307 circuit in the ds1307 data sheet.
Use it. Make sure you have the 4.7K pullup resistors, and make sure
you have the 3v lithium battery on the Vbat pin. All of this is shown
in the schematic.


OK,
but in my hardware SCL = pin0 port C and SDA is pin1 portC
so I can't use those ready made I2C functions...
temtronic



Joined: 01 Jul 2010
Posts: 9164
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Nov 29, 2011 10:50 am     Reply with quote

Yes you can..
at the top of the driver ,just change the defines for which pins are used for the RTC clk and data.
artohautala



Joined: 17 Nov 2011
Posts: 187

View user's profile Send private message Send e-mail

PostPosted: Tue Nov 29, 2011 11:02 am     Reply with quote

temtronic wrote:
Yes you can..
at the top of the driver ,just change the defines for which pins are used for the RTC clk and data.


please tell me exactly how?

those ready made I2C functions are for pins RC3 and RC4
( Iuse PIC18F452 IC)

thank's for your answer
sorry I'm beginner in getting RTCclock module to work ...
temtronic



Joined: 01 Jul 2010
Posts: 9164
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Nov 29, 2011 12:48 pm     Reply with quote

First copy the 1307 'driver' to my_1307.c
In 'my_1307.c'...

place the following code

#define RTC_SDA PIN_B1
#define RTC_SCL PIN_B2

#use i2c(master, sda=RTC_SDA, scl=RTC_SCL)


...before you see these lines...

BYTE bin2bcd(BYTE binary_value);
BYTE bcd2bin(BYTE bcd_value);

void ds1307_init(void)
{

..........

Just replace B1 and B2 with YOUR I2C pins !!

This will tell the compiler to use YOUR pins and create correct software I2C code.


Be sure to include 'my_1307.c' and remoce the original 1307 driver !
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