Datasheet
month := Soft_I2C_Read(0); // Read weekday/month byte}
Soft_I2C_Stop(); // Issue stop signal}
end;
//-------------------- Formats date and time
procedure Transform_Time() ;
begin
seconds := ((seconds and 0xF0) shr 4)*10 + (seconds and 0x0F);
// Transform seconds
minutes := ((minutes and 0xF0) shr 4)*10 + (minutes and 0x0F);
// Transform months
hours := ((hours and 0xF0) shr 4)*10 + (hours and 0x0F);
// Transform hours
year := (day and 0xC0) shr 6; // Transform year
day := ((day and 0x30) shr 4)*10 + (day and 0x0F);
// Transform day
month := ((month and 0x10) shr 4)*10 + (month and 0x0F);
// Transform month
end;
//-------------------- Output values to Lcd
procedure Display_Time();
begin
Lcd_Chr(1, 6, (day / 10) + 48); // Print tens digit of day
variable
Lcd_Chr(1, 7, (day mod 10) + 48); // Print oness digit of
day variable
Lcd_Chr(1, 9, (month / 10) + 48);
Lcd_Chr(1,10, (month mod 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 mod 10) + 48);
Lcd_Chr(2, 9, (minutes / 10) + 48);
Lcd_Chr(2,10, (minutes mod 10) + 48);
Lcd_Chr(2,12, (seconds / 10) + 48);
Lcd_Chr(2,13, (seconds mod 10) + 48);
end;
//------------------ Performs project-wide init
procedure Init_Main();
begin
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
LCD_Out(1,1,'Date:'); // Prepare and output static text on Lcd
LCD_Chr(1,8,':');
357
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroPASCAL PRO for AVR
CHAPTER 6