
REMOTE Control Unit
LCD Text Writing
Passive Infrared (PIR) Unit
Designer Reference Manual
MOTOROLA
REMOTE Control Unit
65
///////////////////////////////////////
// Then read the contents of the RTC //
// registers, with a READ command //
///////////////////////////////////////
StartBit();
SendI2CByte( RTC_READ ); // RTC_READ == 0xd1
WaitForI2CAcknowledge();
ptr->seconds = GetI2CByte();
SendI2CAcknowledge();
ptr->minutes = GetI2CByte();
SendI2CAcknowledge();
ptr->hours = GetI2CByte();
SendI2CAcknowledge();
ptr->day = GetI2CByte();
SendI2CAcknowledge();
ptr->date = GetI2CByte();
SendI2CAcknowledge();
ptr->month = GetI2CByte();
SendI2CAcknowledge();
ptr->year._8bit.lobyte = GetI2CByte();
ptr->year._8bit.hibyte = 0x20; // century hi byte...fixed for the
// next 99 years!
SET_DATA_TO_OUTPUT; // master sending a NOT ACK
SET_SDA;
OutClock(); // no acknowledge expected here, we generate a clock pulse
StopBit();
} // RTC_Read()
As described before, the on-board real-time clock (RTC) can be updated
from a PC using the ‘pir_plot.exe’ Windows
program. This sends the
current PC time to the MC68HC908GP32, and the MC68HC908GP32
receives the data via the universal asynchronous receiver/transmitter
(UART) receive interrupt at
remote\interrupt.c->SCI_RECEIVE()
(see
[REMOTE:interrup.c]
). When all data has been received, a flag is
set to cause full checksum analysis from
remote\datasort()->RS232CommsCheck()
(see
[REMOTE:datasort.c]
).
RS232CommsCheck()
performs the RS232
receive data acceptance processing and text string formatting. If data
checksum matching occurs, the real-time clock is rewritten with the new
data. This takes place in the call to
remote\rtc.c->SetRTC(&new_time)
(see
[REMOTE:rtc.c]
) from
remote\main.c->main()->RS232CommsCheck()
.
F
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
n
.