Nomination for new function: Auto-set date/time

Questions and discussion about the ZBasic IDE.
Post Reply
stevech
Posts: 715
Joined: 22 February 2006, 20:56 PM

Nomination for new function: Auto-set date/time

Post 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.
mikep
Posts: 796
Joined: 24 September 2005, 15:54 PM

Re: Nomination for new function: Auto-set date/time

Post 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.
Mike Perks
stevech
Posts: 715
Joined: 22 February 2006, 20:56 PM

Post 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.
dlh
Posts: 395
Joined: 15 December 2006, 12:12 PM
Location: ~Cincinnati

Re: Nomination for new function: Auto-set date/time

Post 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.
Post Reply