DS12887 RTC PROGRAMMING IN C

SECTION 16.2: DS12887 RTC PROGRAMMING IN C

In this section we program the DS12887 in 8051 C language. Before you embark on this section, make sure that the basic concepts of the DS12887 chip covered in the first section are understood. Also, review external memory access using 8051 C, as discussed in Chapter 14.

Turning on the oscillator, setting the time and date in C

In Chapter 14 we discussed how to access external memory using 8051 C. We also discussed the details of the DS 12887 in the previous section. In this section we provide the C version of the programs given in the previous section. To access the DS 12887 in Figure 16-2, we use the 8051 C command XBYTE[addr], where addr points to the external address location. Notice that XBYTE is part of the absacc.h library file. The following C program shows how to turn on the oscillator, and set the time and date for the configuration in Figure 16-2.



Reading and displaying the time and date in C

The following C program shows how to read the time, convert it to ASCII, and send it to the PC screen via the serial port.




The following shows how to read and display the date in 8051 C. You can replace the time display portion of the above program with the code below.

Next post:

Previous post: