Content originally posted in LPCWare by cfb on Mon Jul 29 15:05:27 MST 2013
Read Chapter 27 of the LPC1769 User Manual (UM10360) for all the details of how to access the Real-Time Clock. In particular Section 27.6.3.1 describes how the Secs:Mins:Hrs:Day information is stored in the CTIME0 register.
We supply a library module called Clock and an example LPC1769 program called ShowTime with our Astrobe development system. Clock includes the following Oberon-language procedure:
<code>
PROCEDURE* GetHMS*(VAR hh, mm, ss: INTEGER);
VAR
ctime: INTEGER;
BEGIN
SYSTEM.GET(MCU.CTIME0, ctime);
ss := ctime MOD 40H;
mm := LSR(ctime, 8 ) MOD 40H;
hh := LSR(ctime, 16 ) MOD 20H
END GetHMS;
</code>
If you want to translate this to C:
CTIME0 = 0x40024014
MOD is equivalent to %
LSR is equivalent to >>
40H is equivalent to 0x40