Datasheet
}
//-------------------- Formats date and time
void Transform_Time() {
seconds = ((seconds & 0xF0) >> 4)*10 + (seconds & 0x0F); //
Transform seconds
minutes = ((minutes & 0xF0) >> 4)*10 + (minutes & 0x0F); //
Transform months
hours = ((hours & 0xF0) >> 4)*10 + (hours & 0x0F); //
Transform hours
year = (day & 0xC0) >> 6; //
Transform year
day = ((day & 0x30) >> 4)*10 + (day & 0x0F); //
Transform day
month = ((month & 0x10) >> 4)*10 + (month & 0x0F); //
Transform month
}
//-------------------- Output values to LCD
void Display_Time() {
Lcd_Chr(1, 6, (day / 10) + 48); // Print tens digit of day
variable
Lcd_Chr(1, 7, (day % 10) + 48); // Print oness digit of day
variable
Lcd_Chr(1, 9, (month / 10) + 48);
Lcd_Chr(1,10, (month % 10) + 48);
Lcd_Chr(1,15, year + 56); // Print year vaiable + 8
(start from year 2008)
Lcd_Chr(2, 6, (hours / 10) + 48);
Lcd_Chr(2, 7, (hours % 10) + 48);
Lcd_Chr(2, 9, (minutes / 10) + 48);
Lcd_Chr(2,10, (minutes % 10) + 48);
Lcd_Chr(2,12, (seconds / 10) + 48);
Lcd_Chr(2,13, (seconds % 10) + 48);
}
//------------------ Performs project-wide init
void Init_Main() {
Soft_I2C_Init(); // Initialize Soft I2C communication
Lcd_Init(); // Initialize LCD
Lcd_Cmd(LCD_CLEAR); // Clear LCD display
Lcd_Cmd(LCD_CURSOR_OFF); // Turn cursor off
408
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroC PRO for AVR
CHAPTER 6