|
|
View previous topic :: View next topic |
Author |
Message |
Bridgen Guest
|
Dallas DS1302 RTC Problem |
Posted: Tue Apr 09, 2002 2:19 pm |
|
|
I assume that somewhere out there, someone has been using the DS1302 time chip with a Pic (We're using the Pic18f452). We are using the driver module (DS1302.c) provided with the windows compiler (PCH - version 3.083) but we seem to be having some problems.
We've tried many variations, but a sample program that we're using is:
void main() {
byte day = 5;
byte month = 4;
byte year = 99;
byte dow = 3;
byte hr = 11;
byte min = 45;
byte sec = 1;
rtc_init();
delay_ms(500);
rtc_set_datetime(day,mth,year,dow,hr,min);
//We put a delay or start a loop to continuously read the time chip here, with a small delay between reads
rtc_get_time(hr,min,sec);
*************
Later on we try to output hr, min, and sec to our serial lcd screen (which works fine any other time, including an initial output of the time and date before trying to read the time chip). When we do this, we get nothing but zeroes for hr,min,sec (And the same for the year, month, etc.., but we don't need that data anyways). We've tried using the \%2X, \%D, \%U placeholders for printf (and have tried using putc as well) but we still get zeroes. We know our LCD works fine, and we know that we have the DS1302 chip configured properly (it works fine with a Parallax stamp in the same test board).
My question's are:
1. Is it a problem with the DS1302 driver? (I doubt it as I see know similar messages on the board)
2. Is this a bug with the compiler and the relatively new PIC18F452?
3. Has anyone experienced a similar problem? If so, how was it resolved?
We've tried everything...changing the pins (which by default are B1,B2,B3), adding delays (ms, us, cycles), using Fixed or Fast IO, (we're using and want to continue using standard), etc. We're stumped.
Any help would be appreciated!
___________________________
This message was ported from CCS's old forum
Original Post ID: 3690 |
|
|
Hans Wedemeyer Guest
|
Re: Dallas DS1302 RTC Problem |
Posted: Tue Apr 09, 2002 3:00 pm |
|
|
One thing I see as wrong, is the values your are sending.
Setup values need to be BCD, and not binary !
Example: For hour 11 the bcd is 0X11, you are sending 11 which is 0X0B !
Convert your values to BCD and try again.
Let's see who can produce the fastest bin to bcd code !
Hans W
:=We've tried many variations, but a sample program that we're using is:
:=
:=void main() {
:=byte day = 5;
:= byte month = 4;
:= byte year = 99;
:= byte dow = 3;
:= byte hr = 11;
:= byte min = 45;
:= byte sec = 1;
___________________________
This message was ported from CCS's old forum
Original Post ID: 3691 |
|
|
jim capps Guest
|
Re: Dallas DS1302 RTC Problem |
Posted: Tue Apr 09, 2002 4:14 pm |
|
|
rtc_get_time(hr,min,sec);
Your example doesn't show your declarations of the variables in your call to rtc_get_time, but you must pass this function the address of the variables you want to set.
i.e. rtc_get_time(&hr,&min,&sec);
Also the registers are in BCD as the other reply indicated.
Also bit 7 of the seconds register is a clock halt bit and will stop the chip, but your example indicates your writing a small value to the seconds register so this shouldn't be a problem.
___________________________
This message was ported from CCS's old forum
Original Post ID: 3694 |
|
|
Bridgen Guest
|
Re: Dallas DS1302 RTC Problem |
Posted: Wed Apr 10, 2002 11:46 am |
|
|
To respond to both emails:
The reference is handled on the function side of things, in the "rtc_get_time(&hr,&min,&sec)" and the parameters are being passed and modified - we've commented out the function and thrown in some test code to make sure ourselves.
We've tried passing in numbers in other formats as well, including what you suggested. No difference.
I'm beginning to think that there may be a glitch with the way the driver code for the ds1302 pulls the reset bit high, does the set/get operation, and sets it low. Maybe its not high for long enough or something to that effect is happening? We've inserted delays directly into the function (and yes, I've backed up the driver file and restore it whenever we modify the copy - I've thought of that too).
Beginning to give up hope here:)
___________________________
This message was ported from CCS's old forum
Original Post ID: 3710 |
|
|
Hans Wedemeyer Guest
|
Re: Dallas DS1302 RTC Problem |
Posted: Wed Apr 10, 2002 7:07 pm |
|
|
Well I can't suggest anymore, other than I have used the DS1306 which is a similar beast and it works very well.
Please report your findings if/when you find a solution.
___________________________
This message was ported from CCS's old forum
Original Post ID: 3727 |
|
|
Guest
|
|
Posted: Mon Apr 04, 2005 6:01 am |
|
|
Hello
Do you have the ccs code for the DS1306, please ?
Thanks ! |
|
|
|
|
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
|