Difference between revisions of "Modules/clock"
From MSX Game Library
< Modules
(→Settings) |
|||
Line 1: | Line 1: | ||
+ | {{MODULE | ||
+ | |name=clock | ||
+ | |category=Core | ||
+ | |dependency1= | ||
+ | |dependency2= | ||
+ | |dependency3= | ||
+ | |sample1=s_clock | ||
+ | |sample2= | ||
+ | |sample3= | ||
+ | }} | ||
+ | |||
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). | 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). | ||
Line 4: | Line 15: | ||
* [https://map.grauw.nl/resources/rtc/ricoh_rp5c01.pdf Ricoh RP-5C01 manual], | * [https://map.grauw.nl/resources/rtc/ricoh_rp5c01.pdf Ricoh RP-5C01 manual], | ||
* [https://www.msx.org/wiki/Real_Time_Clock_Programming Real Time Clock Programming] (MRC). | * [https://www.msx.org/wiki/Real_Time_Clock_Programming Real Time Clock Programming] (MRC). | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Revision as of 23:49, 4 January 2024
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:
- Ricoh RP-5C01 manual (MSX Assembly Page),
- Real Time Clock Programming (MSX Resource Center).
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
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).
The MSX 2 real-time clock is a Ricoh RP-5C01. For more information about this device: