Difference between revisions of "Modules/clock"

From MSX Game Library

< Modules

 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
The {{MOD|clock}} module allow to use MSX2 Real-time Clock (RTC) features including date and time handle, but also save or load data from the embedded non-volatile RAM (CMOS).
+
{{MODULE
 
+
|name=clock
The MSX 2 real-time clock is a Ricoh RP-5C01. For more information about this device:
+
|category=Device
* [https://map.grauw.nl/resources/rtc/ricoh_rp5c01.pdf Ricoh RP-5C01 manual],
+
|dependency1=
* [https://www.msx.org/wiki/Real_Time_Clock_Programming Real Time Clock Programming] (MRC).
+
|dependency2=
 
+
|dependency3=
== Dependencies ==
+
|sample1=s_clock
* ''None''
+
|sample2=
 
+
|sample3=
== Settings ==
+
}}
 
 
== Usage ==
 
 
 
== Annexe ==
 
* See also: Sample program {{SAMPLE|s_clock}}
 
 
 
== Documentation ==
 
{{FRAME_DOC|clock}}
 
 
 
[[category:Module]][[category:Module/Core]]
 

Latest revision as of 18:00, 14 January 2024

clock

Code: clock.h

Category: Device

Dependencies: None

Samples:

The clock module allow to use MSX2 Real-time Clock (RTC) features including date and time handle, but also save or load data from the embedded non-volatile RAM (CMOS).

Usage

To use this module, include "clock.h" in your source code, and add "clock" to the modules list (LibModules) in your project's configuration file (project_config.js).

For example, display the current year:

RTC_Initialize();
u8 year = RTC_GetYear();
Print_DrawFormat("This year: %i", 1980 + year);

Save data to CMOS memory:

u8 saveData[6];
saveData[0] = 0xFF;
saveData[1] = 100;
saveData[2] = 0;
RTC_SaveData(saveData);

The MSX2 real-time clock is a Ricoh RP-5C01. For more information about this device:

Samples

See module use cases in the sample programs:

Settings

Library configuration (msxgl_config.h):

#define RTC_USE_CLOCK				TRUE	// Add functions to handle date and time
#define RTC_USE_CLOCK_EXTRA			TRUE	// Add extra date and time functions that require additional data
#define RTC_USE_SAVEDATA			TRUE	// Add functions to read/write into the CMOS 
#define RTC_USE_SAVESIGNED			TRUE	// Add signature handling to validate CMOS I/O

Dependencies

Dependency on other modules: None

Documentation