View previous topic :: View next topic |
Author |
Message |
noman yousaf
Joined: 07 Jan 2016 Posts: 17 Location: pakistan
|
RTC problem |
Posted: Fri Jan 08, 2016 8:01 pm |
|
|
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
|
|
|
noman yousaf
Joined: 07 Jan 2016 Posts: 17 Location: pakistan
|
|
Posted: Sat Jan 09, 2016 7:06 am |
|
|
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
|
|
Posted: Sat Jan 09, 2016 9:03 am |
|
|
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
|
|
Posted: Thu Jan 14, 2016 5:47 pm |
|
|
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
|
|
Posted: Thu Jan 14, 2016 5:53 pm |
|
|
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
|
|
Posted: Thu Jan 14, 2016 7:08 pm |
|
|
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. |
|
|
|