User`s manual

BL160038 s System Development
GENDMA.C in the SAMPLES\BL16XX directory illustrates the use of DMA
functions.
Battery-Backed Clock
The battery-backed clock retains the time and date with a resolution of one
second, and an accuracy of about one second per day. It automatically
accounts for leap year.
The following structure is used to hold the time and date:
struct tm {
char tm
_
sec; // 0-59
char tm
_
min; // 0-59
char tm
_
hour; // 0-23
char tm
_
mday; // 1-31
char tm
_
mon; // 1-12
char tm
_
year; // 0-150 (1900-2050)
char tm
_
wday; // 0-6 where 0 means Sunday
};
The following routines are used to read and write the clock.
int tm
_
wr( struct tm *x ); // write the clock
int tm_rd( struct tm *x ); // read the clock
The following routines convert the time to and from a long integer. The
long-integer format represents the number of seconds that have passed
since January 1, 1980 at midnight (00:00:00).
// return long seconds from structure
long mktime( struct tm *t );
// return structure from long seconds
int mktm( struct tm *t, long time );
The long-integer format is convenient for comparing dates and times. The
mktime function correctly handles dates beyond the year 2000.
Writing to Flash EPROM
int WriteFlash( unsigned long addr, char* buf,
int num )
Writes num bytes from buf to flash EPROM, starting at addr. addr is
an absolute physical address.
To do this, allocate flash data in the Dynamic C program by declaring
initialized variables or arrays, or by initialized xdata. For xdata,
pass the data name directly to the following function.
xdata my_data { 0, 0xFF, 0x08 };
...
WriteFlash( my
_
data, my
_
buffer, my
_
count );