DS3231 - RTC Time Keeper

A forum where Flowcode v6 user created components can be shared, discussed and reviewed.

Moderator: Benj

hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times
Contact:

Re: DS3231 - RTC Time Keeper

Postby hyperion007 » Sat May 17, 2014 6:34 am

With 1.6 the dashboard "icon" showed the original I2C icon with the DS3231 name, but had the LCD icon "stuck" under the I2C icon :)

I'm going to use the alarm function to wake the PIC up from sleep mode at precise intervals, when the alarm function is working that is ;)

John, if you want I can make the PCB available for ordering from OSH Park and post the very simple schematic and short BOM.

User avatar
Crenwick
Posts: 127
Joined: Sun Aug 07, 2011 1:40 pm
Location: Belgium
Has thanked: 7 times
Been thanked: 21 times
Contact:

Re: DS3231 - RTC Time Keeper

Postby Crenwick » Sun Jun 01, 2014 10:17 am

Hi Jordy,

I'm using your component in my project and I'm facing a problem, when I power off the board the clock stay at the same time. It's like bit EOSC is set.

I supposed you cleared this bit with initializing macro ? Right ?

Regards,
Bernard

Flowcode 6 / EB006-V9

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 27 times
Been thanked: 190 times
Contact:

Re: DS3231 - RTC Time Keeper

Postby Jordy101091 » Sun Jun 01, 2014 11:04 am

I will look into this, I apologise to all of you for not being so active lately.
I was looking for a new and first car for my self and that took a lot of my free time.
I hope you all can understand this :)

But I promise that I will become more active in the future.

Regards Jordy
the will to learn, should not be stopped by any price

User avatar
Crenwick
Posts: 127
Joined: Sun Aug 07, 2011 1:40 pm
Location: Belgium
Has thanked: 7 times
Been thanked: 21 times
Contact:

Re: DS3231 - RTC Time Keeper

Postby Crenwick » Sun Jun 01, 2014 11:12 am

No problem Jordy :wink:

Take your time !
Bernard

Flowcode 6 / EB006-V9

User avatar
Crenwick
Posts: 127
Joined: Sun Aug 07, 2011 1:40 pm
Location: Belgium
Has thanked: 7 times
Been thanked: 21 times
Contact:

Re: DS3231 - RTC Time Keeper

Postby Crenwick » Mon Jun 02, 2014 8:13 am

Hi Jordy,

I find the problem :wink:

Each time you configure the SQW rate you set also bit 7 (adding 0x80) who is disabling oscillator when on Vbat.

Actual Macro,

case 2:
{
//Comment:
//Enable Square Wave Output
//Frequency = 1Hz

FCD_005f1_I2C_Master1__TransmitByte(0x80);

break;
}
case 3:
{
//Comment:
//Enable Square Wave Output
//Frequency = 1.024kHz

FCD_005f1_I2C_Master1__TransmitByte(0x88);

break;
}
case 4:
{
//Comment:
//Enable Square Wave Output
//Frequency = 4.096kHz

FCD_005f1_I2C_Master1__TransmitByte(0x90);

break;
}
case 5:
{
//Comment:
//Enable Square Wave Output
//Frequency = 8.192kHz

FCD_005f1_I2C_Master1__TransmitByte(0x98);

break;
}
// default:

Can you mod the component :wink: ?

Regards,
These users thanked the author Crenwick for the post:
medelec35 (Sat Jun 27, 2015 9:01 am)
Rating: 5.88%
 
Bernard

Flowcode 6 / EB006-V9

hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times
Contact:

Re: DS3231 - RTC Time Keeper

Postby hyperion007 » Mon Jun 02, 2014 10:36 am

Crenwick, could you please try the alarm functions as well? I cannot seem to get them working. I have tried both alarms, and many different settings but still nothing.

User avatar
Crenwick
Posts: 127
Joined: Sun Aug 07, 2011 1:40 pm
Location: Belgium
Has thanked: 7 times
Been thanked: 21 times
Contact:

Re: DS3231 - RTC Time Keeper

Postby Crenwick » Mon Jun 02, 2014 11:34 am

hyperion007 wrote:Crenwick, could you please try the alarm functions as well? I cannot seem to get them working. I have tried both alarms, and many different settings but still nothing.


Ok, I will test it :wink:
Bernard

Flowcode 6 / EB006-V9

User avatar
Crenwick
Posts: 127
Joined: Sun Aug 07, 2011 1:40 pm
Location: Belgium
Has thanked: 7 times
Been thanked: 21 times
Contact:

Re: DS3231 - RTC Time Keeper

Postby Crenwick » Sun Jun 08, 2014 4:36 pm

Sorry for late reply, I tested and have no trigger from INT/SQW.

Just received my buspirate this week and will test the I2C analysys tool :wink:
Bernard

Flowcode 6 / EB006-V9

hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times
Contact:

Re: DS3231 - RTC Time Keeper

Postby hyperion007 » Mon Jun 09, 2014 10:13 am

Thanks, that confirms my findings as well :(

hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times
Contact:

Re: DS3231 - RTC Time Keeper

Postby hyperion007 » Sun Jun 15, 2014 7:58 am

Hi Jordy,

Any updates to the component? Kinda need the alarm functions etc :)

hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times
Contact:

Re: DS3231 - RTC Time Keeper

Postby hyperion007 » Fri Aug 01, 2014 12:48 pm

I have fixed the EOSC problem but cannot for the life of me figure out why the alarm rates aren't working.

hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times
Contact:

Re: DS3231 - RTC Time Keeper

Postby hyperion007 » Fri Aug 01, 2014 1:50 pm

If anyone want's to try it as is I have uploaded my revised version of the component.

Things to note are that I think only Alarm 2 once per minute rate works. Alarm 1 will probably not work at all.

But I do believe I have fixed the problem with the OSC shutting down when in Vbat state.

I just really needed to get the INT every minute to work and couldn't wait any longer.

DS3231.fcpx
Component version 2.1
(9.85 KiB) Downloaded 175 times

hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times
Contact:

Re: DS3231 - RTC Time Keeper

Postby hyperion007 » Sun Aug 03, 2014 11:11 am

If anyone that has a DS3231 could connect it up and also connect a display, then run a simple program (first you need to write time and date if that hasn't been done yet) that in the main loop reads the time and return it as a string, then display it on the display.

Keep this running for several days and just check it from time to time to see that it is not drifting in any way, time wise.

Mine has been running for a couple of days now and was doing just fine when I went to bed last night at 00:30 (so this morning really) but when I checked it at 07:31 this morning, it was showing something like 06:45

We did have some severe thunder and lightning last night but it shouldn't affect this... It would be nice to see if anyone else are having some "long term" issues.

I did in fact have it return a time saying such things as 29 hours and also 25 hours. This was a month ago I think, after having the DS3231 unplugged for a month maybe. It might have had something to do with the component setting the EOSC bit incorrectly before, I don't know. But it's good to have more people testing it.

hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times
Contact:

Re: DS3231 - RTC Time Keeper

Postby hyperion007 » Tue Aug 05, 2014 11:05 am

I have now made some more tests with a second chip from this batch and it is also acting up, so if you see this Jordy, please check your's if you can but if not, just replace the chip with a DS3231SN directly Maxim Integrated or Mouser/Digikey etc.

"Good deals" from Ebay proving not to be that great : :evil:

hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times
Contact:

Re: DS3231 - RTC Time Keeper

Postby hyperion007 » Wed Aug 13, 2014 10:17 am

I got the new IC's from Maxim Integrated on Monday and so far it is working just fine, not like the other IC's.

So I'll leave it running for a couple of days more but I think it's proof enough that the ebay IC's I got was faulty.
These users thanked the author hyperion007 for the post:
Benj (Wed Aug 13, 2014 10:46 am)
Rating: 5.88%
 

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 27 times
Been thanked: 190 times
Contact:

Re: DS3231 - RTC Time Keeper

Postby Jordy101091 » Sun Aug 17, 2014 6:51 pm

Hi all,

First I want to apologize to you all, for not being a very active member lately.
But im trying to changes this, and want to start with fixing the problems you all have with this component.

The main issue as from what I understand, is that the alarm functions did not operated properly.
I have made some little changes in the code as well as the component properties window. Now you are able to disable timer 1 and 2, which seem to cause some
issues with initialization routine, If both alarms are disabled the program automatically disables the Alarm Interrupt Enable settings, so that there is a minimal change of conflict situations.

Also I have changed the clear alarm routine, so that takes fewer lines of code and therefore makes it more clearer, and a bit faster as well.

To use the alarms correctly you need to first set the function of the alarm (Alarm "nr"" Rate) in the properties window. If this is done you need to set the alarm information with the macro "SetAlarm1/2".
You need to periodically check the status flag of alarm to know if it has triggered, or you could use an interrupt for that as well. Ones an alarm event is happend you need to clear the alarm with the "ClearAlarms" Macro before another alarm event can happen.

I hope This clarifies a bit.

You can download version 1.66 from the mean post.

Regards Jordy
the will to learn, should not be stopped by any price

hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times
Contact:

Re: DS3231 - RTC Time Keeper

Postby hyperion007 » Sun Aug 17, 2014 6:56 pm

Thanks Jordy.

I can report that the problems I had with the RTC being reprogrammed seems to have been caused by me putting a delay in the INT routine for the alarm and also putting the clear alarm macro in the same INT routine. I do not know how this could cause the RTC time registers to get corrupted but they did.

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 27 times
Been thanked: 190 times
Contact:

Re: DS3231 - RTC Time Keeper

Postby Jordy101091 » Sun Aug 17, 2014 7:02 pm

Oke,

Another thing I have noticed here on this topic is that the RTC won't tick when VDD is removed from the chip.

mmm... where did I see that message.
O wait here it is:

Hi Jordy,

I'm using your component in my project and I'm facing a problem, when I power off the board the clock stay at the same time. It's like bit EOSC is set.

I supposed you cleared this bit with initializing macro ? Right ?

Regards,


Im a bit confused because when I power down the RTC by removing the VDD wire and re-connect that same wire 30 seconds later, the time on the RTC is correctly incremented 30 seconds.
Maybe Crenwick had bad battery perhaps.

Regards Jordy
the will to learn, should not be stopped by any price

hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times
Contact:

Re: DS3231 - RTC Time Keeper

Postby hyperion007 » Sun Aug 17, 2014 7:06 pm

There was a problem with the EOSC bit being cleared when clearing the alarms/checking the status. I think I corrected it in my not so pretty version :)

There wouldn't be any problem if you didn't clear any alarms and such, then it would still run on Vbat.

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 27 times
Been thanked: 190 times
Contact:

Re: DS3231 - RTC Time Keeper

Postby Jordy101091 » Sun Aug 17, 2014 7:09 pm

Well that problem is now resolved,
Because I now use the XOR function the clear the alarm flags so the EOSC bit stays unchanged.
So this problem belongs to the past.

Regards Jordy
These users thanked the author Jordy101091 for the post (total 2):
dazz (Sun Aug 17, 2014 7:11 pm) • JohnCrow (Sun Aug 17, 2014 8:19 pm)
Rating: 11.76%
 
the will to learn, should not be stopped by any price

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 27 times
Been thanked: 190 times
Contact:

Re: DS3231 - RTC Time Keeper

Postby Jordy101091 » Tue Aug 19, 2014 7:27 pm

Just for kicks,

I have added a option to choose between 24 Hr and 12 Hr (AM/PM) notation.
I thought this would be helpful since its also available in the DS1307 Component.

So Component is updated to version 1.67, download can be done from the main post.

Regards Jordy
the will to learn, should not be stopped by any price

hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times
Contact:

Re: DS3231 - RTC Time Keeper

Postby hyperion007 » Tue Aug 19, 2014 9:10 pm

Good, now while you're at it, could you make a macro for changing the alarm rate? It can be set to once per second, once per minute, once per hour, once per day etc. using the mask bits. It would be very good to be able to change rate from within the program.


Thanks.

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 27 times
Been thanked: 190 times
Contact:

Re: DS3231 - RTC Time Keeper

Postby Jordy101091 » Tue Aug 19, 2014 9:15 pm

hyperion007 wrote:Good, now while you're at it, could you make a macro for changing the alarm rate? It can be set to once per second, once per minute, once per hour, once per day etc. using the mask bits. It would be very good to be able to change rate from within the program.


Thanks.


Consider it handled,

But would you prefer to have a separate macro for changing the alarm rate or does it need to added with the SerAlarm macro. Also do I need to remove that option from the properties window or leave that as it is.

Regards jordy
the will to learn, should not be stopped by any price

hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times
Contact:

Re: DS3231 - RTC Time Keeper

Postby hyperion007 » Wed Aug 20, 2014 3:54 am

I think it would be less confusing if it was a separate macro from the set alarm macro.
Because when an alarm has been set once, changing the masking bits would change the rate without the need to change the alarm time (setAlarm)

I think you can leave it in the properties window, it's fine. But maybe add the different rates here as well because now it's only every second and every minute then other specific alarms like when minutes match etc. Missing are the once per hour, once per day etc.

Thanks.
These users thanked the author hyperion007 for the post:
Jordy101091 (Wed Aug 20, 2014 6:26 am)
Rating: 5.88%
 

User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 27 times
Been thanked: 190 times
Contact:

Re: DS3231 - RTC Time Keeper

Postby Jordy101091 » Thu Aug 21, 2014 6:56 pm

I have updated the component to version 1.68.

In this version it is now possible to change the alarm match condition on the fly.
The uC doesn't need reprogramming to change alarm match conditions.

Download can be done from the start post.

Regards Jordy
These users thanked the author Jordy101091 for the post (total 4):
hyperion007 (Thu Aug 21, 2014 7:04 pm) • medelec35 (Thu Aug 21, 2014 7:21 pm) • dazz (Thu Aug 21, 2014 9:10 pm) • mohandino (Thu May 14, 2015 6:00 pm)
Rating: 23.53%
 
the will to learn, should not be stopped by any price