Set VS1010D RTC time from file system

Designing hardware and software for systems that use the VS1010 MP3 Audio DSP Microcontroller.
Post Reply
User avatar
Panu
VLSI Staff. Currently on holiday.
Posts: 2733
Joined: Tue 2010-06-22 13:43

Set VS1010D RTC time from file system

Post by Panu » Thu 2020-01-02 18:24

Dear all,

Here's a VS1010D utility program to set the current time of the RTC to whatever is the latest file creation or modification time in a given directory, if it's later than the current time of the RTC.

Usage: SetTimeFrom [?][!][folderspec]

Folderspec can be a drive such as S: or D: or a subdirectory such as S:SYS or D:MUSIC. If folderspec is omitted, then S: is used as the default. Question mark prints the current RTC time or the default time if RTC is clearly messed up. Exclamation mark forces the RTC value to be set.

When invoked, the program scans all file entries in a given directory and determines which file entry has the largest creation or modification timestamp. If that is beyond the current value of the hardware RTC counter, the value of the hardware RTC counter is updated.

For example:
VSOS Console wrote:VS1010>settimefrom !0:
No device 0.
Time of RTC is 2000-01-01 00:00:00
Updating RTC hardware register...

VS1010>settimefrom ?
Time of RTC is 2000-01-01 00:00:05

VS1010>settimefrom
Time of CONFIG.TXT is 2020-01-02 13:06:32
Updating RTC hardware register...

VS1010>settimefrom S:SYS
Time of SETTIM~1.DLX is 2020-01-02 16:57:20
Updating RTC hardware register...

VS1010>settimefrom S:
Time of RTC is 2020-01-02 16:57:30

VS1010>settimefrom !S:
Time of CONFIG.TXT is 2020-01-02 13:06:32
Updating RTC hardware register...

VS1010>settimefrom ?
Time of RTC is 2020-01-02 13:06:59

VS1010>settimefrom ?
Time of RTC is 2020-01-02 13:07:04

VS1010>
Additionally, if your goal is to get correct timestamps to files written by the VSOS, you need to RunLib("RTCREAD",NULL); to update the system time from the RTC hardware before closing a file. This step can be automated by setting a handler for the GetTimeFromRtc system hook.

See also: RTC aware file copy.

-Panu
Attachments
arch-SetTimeFrom-2020-01-02-18-22-RC1.zip
Utility to set system time from latest timestamp in a FAT directory. VSIDE Solution with source code. Includes VS1010 VSOS executable SetTimeFrom.dlx
(35.32 KiB) Downloaded 87 times
Info: Line In and Line Out, VS1000 User interface, Overlay howto, Latest VSIDE, MCU Howto, Youtube
Panu-Kristian Poiksalo, VLSI Solution Oy

Post Reply