Hardware Reference
In-Depth Information
mdy[7] 5 0x30 1 (cur_time[6] & 0x0F);
mdy[8] 5 0;
/* NULL character */
}
}
Example 11.8
Write a function to display the current time and calendar information on the LCD.
Solution: This function is as follows:
void displayTime(void)
{
cmd2lcd(0x83);
/* set cursor to row 1 column 3 */
puts2lcd(hms);
/* output hours, minutes, and seconds */
cmd2lcd(0xC3);
/* set cursor to row 2 column 3 */
puts2lcd(mdy);
/* output month, date, and year */
}
Example 11.9
Write the IRQ interrupt service routine that reads the time from the DS1307, format the
time and calendar information, and display them on the LCD.
Solution: The IRQ service routine simply calls the previous functions that have been written.
The C language version of the service routine is as follows:
#pragma interrupt_handler irqISR
// CodeWarrior format
void irqISR(void)
{
readTime(0x00);
/* read all time registers starting from seconds */
formatTime();
/* format time info into two strings */
displayTime();
/* display the time on LCD */
}
11.7 The Digital Thermometer and Thermostat DS1631A
Many embedded products, such as network routers and switches, are used in larger sys-
tems, and their failures due to overheating could severely damage the functioning or even cause
the total failure of the larger system. Using a thermostat to warn of potential overheating is
indispensable for the proper functioning of many embedded systems.
The digital thermostat device DS1631A from Dallas Semiconductor is one such product. The
DS1631A will assert a signal (T OUT ) whenever the ambient temperature exceeds the trip point
preestablished by the user. The DS1626 performs the same function but has an SPI interface.
 
Search WWH ::




Custom Search