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

RTC problem

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



Joined: 07 Jan 2016
Posts: 17
Location: pakistan

View user's profile Send private message Send e-mail Visit poster's website

RTC problem
PostPosted: Fri Jan 08, 2016 8:01 pm     Reply with quote

hi,

I opened 2416.c
and changed the device address from 0A to 0D (for DS1307 RTC).
and removed oring for use the 3 msb address bits.
then i saved it as 1307.c

will it work as RTC instead of EEPROM?
please guide
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jan 08, 2016 8:37 pm     Reply with quote

No. Not at all.
Use the real ds1307 driver:
http://www.ccsinfo.com/forum/viewtopic.php?t=23255
noman yousaf



Joined: 07 Jan 2016
Posts: 17
Location: pakistan

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Sat Jan 09, 2016 7:06 am     Reply with quote

PCM programmer wrote:
No. Not at all.
Use the real ds1307 driver:
http://www.ccsinfo.com/forum/viewtopic.php?t=23255



in that code, there is an error in DS1307.c (the code written in upper)
error is about pinc3,c4.
and there is no any definition of controller etc in such code.
temtronic



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

View user's profile Send private message

PostPosted: Sat Jan 09, 2016 9:03 am     Reply with quote

these lines in the driver...

#define RTC_SDA PIN_C4
#define RTC_SCL PIN_C3

define(tell the driver) which pins YOU attach the DS1307 to.

From your description you're probably using a PIC that does NOT have C3 or C4 I/O pins.

simple copy the driver to my_1307.c
edit these lines
#define RTC_SDA PIN_C4
#define RTC_SCL PIN_C3
replacing PIN_C4 with the pin YOU want to be the 'data' pin
and repalce PIN_C3 with the pin YOU want to be the 'clock' pin

You should not edit the original ds1307.c driver code otherwise you can easily 'damage' it.

jay
noman yousaf



Joined: 07 Jan 2016
Posts: 17
Location: pakistan

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Thu Jan 14, 2016 5:47 pm     Reply with quote

temtronic wrote:
these lines in the driver...

#define RTC_SDA PIN_C4
#define RTC_SCL PIN_C3

define(tell the driver) which pins YOU attach the DS1307 to.

From your description you're probably using a PIC that does NOT have C3 or C4 I/O pins.

simple copy the driver to my_1307.c
edit these lines
#define RTC_SDA PIN_C4
#define RTC_SCL PIN_C3
replacing PIN_C4 with the pin YOU want to be the 'data' pin
and repalce PIN_C3 with the pin YOU want to be the 'clock' pin

You should not edit the original ds1307.c driver code otherwise you can easily 'damage' it.

jay


I am using pic18f458 which has pins C4 and C3.
noman yousaf



Joined: 07 Jan 2016
Posts: 17
Location: pakistan

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Thu Jan 14, 2016 5:53 pm     Reply with quote

noman yousaf wrote:
temtronic wrote:
these lines in the driver...

#define RTC_SDA PIN_C4
#define RTC_SCL PIN_C3

define(tell the driver) which pins YOU attach the DS1307 to.

From your description you're probably using a PIC that does NOT have C3 or C4 I/O pins.

simple copy the driver to my_1307.c
edit these lines
#define RTC_SDA PIN_C4
#define RTC_SCL PIN_C3
replacing PIN_C4 with the pin YOU want to be the 'data' pin
and repalce PIN_C3 with the pin YOU want to be the 'clock' pin

You should not edit the original ds1307.c driver code otherwise you can easily 'damage' it.

jay


I am using pic18f458 which has pins C4 and C3.



can i not use #use12c. . , for making my own code to drive any i2c device? for example, in 24cxx i2c is used. i just want to make new code using i2c for rtc by changing device code (odh)
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jan 14, 2016 7:08 pm     Reply with quote

Quote:
and there is no any definition of controller etc in such code.

There sure is. See this section in the driver link:
Quote:

Example use:

#include <18F452.h>
#device adc=8
#fuses NOWDT,WDT128,HS, NOPROTECT, NOOSCSEN, BROWNOUT, BORV20, NOPUT, STVREN, NODEBUG, NOLVP, NOWRT, NOWRTD, NOWRTB, NOWRTC, NOCPD, NOCPB, NOEBTR, NOEBTRB
#use delay(clock=20000000,RESTART_WDT)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=PC,errors)

#include <ds1307.c>

The controller in the example is the 18F452, but you can change it.
Note that the driver is saved as ds1307.c and then an #include line is used
to include it in the example file. This is the normal way of doing a program.

ds1307 driver and example file:
http://www.ccsinfo.com/forum/viewtopic.php?t=23255



Quote:
i just want to make new code using i2c for rtc by changing device code (0dh)

It won't work. An eeprom chip is entirely different than an RTC chip.
You must use a driver file written for the ds1307.
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