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

DS1307, send me bad values....

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



Joined: 17 May 2013
Posts: 8

View user's profile Send private message

DS1307, send me bad values....
PostPosted: Tue Jul 02, 2013 2:40 pm     Reply with quote

Hi, greetings, now i have a problem please if you could help me, this gonna be wonderful.

I trying use a DS1307 clock, and i use this lib: http://www.ccsinfo.com/forum/viewtopic.php?t=23255 but in the serial port monitor, (included in this compiler, this is the result
Code:

45 85 85
45 85 85
45 85 85
45 85 85
45 85 85
45 85 85
45 85 85
45 85 85


Obviously this values are wrong, but i cant find the error... please could you help me

This is the code:
Code:

#include <18F4520.h>

#FUSES HS   
#FUSES NOWDT                //No Watch Dog Timer
#FUSES NOPROTECT
#FUSES NOLVP                //No low voltage programing

#use delay (clock=20000000) //Fosc=20Mhz

//Configuracion RS232
#use fixed_io(c_outputs=PIN_C6)
#use rs232(baud=9600, parity=N, xmit=PIN_C6, rcv=PIN_C7, bits=8, stream=RS232)

#include <ds1307.c>

void main(){
    BYTE sec;
    BYTE min;
    BYTE hrs;
    ds1307_init();

    //Set date for->15 June 2005 Tuesday
    //Set time for->15:20:55
    ds1307_set_date_time(15,6,5,2,15,20,55);

    while(TRUE){
        delay_ms(1000);
        ds1307_get_time(hrs,min,sec);
        printf("%d %d %d",hrs,min,sec);
        printf("\r\n");
    }
}
temtronic



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

View user's profile Send private message

PostPosted: Tue Jul 02, 2013 5:29 pm     Reply with quote

hardware...
do you have the correct I2C bus pullup resistors ? typically 3k3r or 4k7r will work.

do you have a battery connected to the DS1307 ? it's needed for proper operation


hth
jay
aasanchez



Joined: 17 May 2013
Posts: 8

View user's profile Send private message

PostPosted: Tue Jul 02, 2013 5:43 pm     Reply with quote

No have battery, and resitors is 4k7... Thanks a lot...
temtronic



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

View user's profile Send private message

PostPosted: Tue Jul 02, 2013 7:25 pm     Reply with quote

hmmm.. just noticed you've used 'fixed_io'...
I'd remove that,recompile, and see what happens.

Normally, for 99.999999% of the programs ever seen here, you do NOT need to use fixed_io. Let the compiler handle the 'details' as it sees to.
Unless you need really tight, fast code( not needed here...) using 'fast_io' an cause you 'problems'.

hth
jay
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

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

PostPosted: Wed Jul 03, 2013 12:41 am     Reply with quote

aasanchez wrote:
No have battery, and resitors is 4k7... Thanks a lot...


The DS1307 will not work correctly or reliably with the battery terminal floating (no battery or unconnected battery). During development this can be easily fixed using either a pull up resistor or pull down resistor - it does not matter which.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
fatalyric



Joined: 21 Aug 2013
Posts: 2

View user's profile Send private message MSN Messenger

Re: DS1307, send me bad values....
PostPosted: Wed Aug 21, 2013 1:13 pm     Reply with quote

aasanchez wrote:
Hi, greetings, now i have a problem please if you could help me, this gonna be wonderful.


Code:

45 85 85
45 85 85
45 85 85
45 85 85
45 85 85
45 85 85
45 85 85
45 85 85




I have this problem :( Need help pls (I use 18f4580, SDA=B5 SCL=B6 ===> I edited ds1307.c )
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Aug 21, 2013 1:20 pm     Reply with quote

1. Don't use pins B6 or B7 for i2c. They are used by the ICD debugger/programmer.

2. Make sure you have a 3 volt battery connected to the Vbat pin.
fatalyric



Joined: 21 Aug 2013
Posts: 2

View user's profile Send private message MSN Messenger

PostPosted: Fri Aug 23, 2013 9:31 am     Reply with quote

PCM programmer wrote:
1. Don't use pins B6 or B7 for i2c. They are used by the ICD debugger/programmer.

2. Make sure you have a 3 volt battery connected to the Vbat pin.


I hate I2C, ahahaha Very Happy
proteus simulator work fine Cool , but real is
45 85 85
45 85 85
45 85 85
Shocked
temtronic



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

View user's profile Send private message

PostPosted: Fri Aug 23, 2013 9:37 am     Reply with quote

The real problem is that Proteus is NOT working according to the REAL hardware! We all know Proteus is full of bugs, erros, faulty DRCs...

The numbers you show us, tell us, that you do not have a 3 volt battery connected to the DS1307. The datasheet clearly states you MUST have one connected in order for the RTC to function properly.
I've used 1307s for years, have hundreds in the real world, all work fine.

If you still have problems then post your schematic as well as a picture of the hardware setup.

hth
jay
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