Page 1 of 1
Nomination for new function: Auto-set date/time
Posted: 07 January 2007, 13:29 PM
by stevech
When the IDE downloads new code to the ZX, it would be nice if it by default sends the date/time (from the PC's clock) to initialize the VM's date/time keeping. I suppose there could be a user-option to disable this.
Re: Nomination for new function: Auto-set date/time
Posted: 07 January 2007, 13:44 PM
by mikep
stevech wrote:When the IDE downloads new code to the ZX, it would be nice if it by default sends the date/time (from the PC's clock) to initialize the VM's date/time keeping. I suppose there could be a user-option to disable this.
This is a good idea but has some limitations.
The problem is that unless some specific action is taken that downloaded time lasts exactly until the next power on.
So if the user has a RTC circuit with battery backup, this downloaded time could be transferred to the RTC. The time would have to be downloaded last. Even so the time would be not quite correct.
Posted: 07 January 2007, 14:00 PM
by stevech
Currently, I have code that saves the date/time to RAM that survives a VM-restart. Once a second it saves this to the RAM area. And restores this to the VM clock upon a reset.
I use this instead of a clock chip. It loses a couple of seconds when there's a reset due to DTR toggling (grrrr) when a serial port terminal launches. But it's good enough. The hiding place I use in RAM is a hack for sure. My application, of course, accepts date/time setting via a serial port command.
I uploaded to this forum the code to hide date/time in RAM during a reset.
Re: Nomination for new function: Auto-set date/time
Posted: 07 January 2007, 15:12 PM
by dlh
stevech wrote:When the IDE downloads new code to the ZX, it would be nice if it by default sends the date/time (from the PC's clock) to initialize the VM's date/time keeping. I suppose there could be a user-option to disable this.
I don't use the IDE but always download from within my Windows application and am currently revising it to do everything using native VB code rather than the ZBasic DLL. As soon as it is debugged I'll send Don a small VB app that demonstrates downloading software and updating the VM using all native VB code.
Whenever it resets, my ZBasic code sends a request to the PC to update the timestamp. For standalone operation I'm adding an optional battery-backed RTC using the ST M41T81. The app will auto-detect the M41T81 and use it when available. The M41T81 has calibration registers to allow fine tuning its accuracy and also can track how long power was off - it updates the time in the background but doesn't update the output registers. When power is restored you can first get the time it was lost and then update the output registers and get the current time.