Updating the DS1307 RTC Driver - If you like using it please read this post!!!
Kye
Posts: 2,200
Hey guys,
I've been making alot of changes to my library code and included in my library of code is my DS1307 RTC clock driver that seems to be liked by alot of people.
So, I would like to pass the changes by everyone so that the best option can be choosen for how the new code will work.
Basically, the DS1307 RTC driver I have posted only executes data transfers one byte·at a time. This can be a problem when you grab a full time stamp. What happens is that the DS1307 keeps counting in the background between byte·data transfers. The only way to stop it from counting in the background is to grab all the time and date byte·info at once in one data transfer.
Thus to fix these issues I re-wrote the code so that it always executes data transfers of the time and date info as block transfers. (Setting the SQWOUT pin·and SRAM are still single byte transfers and work fine.)
So, to set the time I now have one function which just takes the current (seconds, minutes, hours, day, date, month, and year). I don't think anyone should have a problem with this because you usually need to set the whole time at once anyway.
However, for getting the current time I'm having alot of issues on how I should proceed.·The only way which I can guarentee everything will work·out correctly is by making the "checkTime" function which gets the current time take a pointer to a struct which it will then populate with the current time. However, as·SPIN has no support for structs this approach will be akward.
I have to devise a solution to this problem that will not have multi-include problems or multi-processor problems. So, if anyone has any ideas about this please speakup.·Thanks you.
...
Attached is·a version of the driver where I thought I had fixed all problems. However, if two processors·were to try to get the time at·once a problem could occur when one core is updating the time and the other is ampling the time. This is·why I cannot just use variable space within the driver to solve this dilema.
Thanks, for your help.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
I've been making alot of changes to my library code and included in my library of code is my DS1307 RTC clock driver that seems to be liked by alot of people.
So, I would like to pass the changes by everyone so that the best option can be choosen for how the new code will work.
Basically, the DS1307 RTC driver I have posted only executes data transfers one byte·at a time. This can be a problem when you grab a full time stamp. What happens is that the DS1307 keeps counting in the background between byte·data transfers. The only way to stop it from counting in the background is to grab all the time and date byte·info at once in one data transfer.
Thus to fix these issues I re-wrote the code so that it always executes data transfers of the time and date info as block transfers. (Setting the SQWOUT pin·and SRAM are still single byte transfers and work fine.)
So, to set the time I now have one function which just takes the current (seconds, minutes, hours, day, date, month, and year). I don't think anyone should have a problem with this because you usually need to set the whole time at once anyway.
However, for getting the current time I'm having alot of issues on how I should proceed.·The only way which I can guarentee everything will work·out correctly is by making the "checkTime" function which gets the current time take a pointer to a struct which it will then populate with the current time. However, as·SPIN has no support for structs this approach will be akward.
I have to devise a solution to this problem that will not have multi-include problems or multi-processor problems. So, if anyone has any ideas about this please speakup.·Thanks you.
...
Attached is·a version of the driver where I thought I had fixed all problems. However, if two processors·were to try to get the time at·once a problem could occur when one core is updating the time and the other is ampling the time. This is·why I cannot just use variable space within the driver to solve this dilema.
Thanks, for your help.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Timothy D. Swieter, E.I.
www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, 3.0" 16:9 LCD Composite video display, eProto for SunSPOT, PropNET, PolkaDOT-51
www.tdswieter.com
My problem is what to do with the data after getting it. You can't return multiple values. So either I take a pointer to a struct or something else.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,