Datasheet

'-------------------- Formats date and time
sub procedure Transform_Time()
seconds = ((seconds and 0xF0) >> 4)*10 + (seconds and 0x0F) '
Transform seconds
minutes = ((minutes and 0xF0) >> 4)*10 + (minutes and 0x0F) '
Transform months
hours = ((hours and 0xF0) >> 4)*10 + (hours and 0x0F) '
Transform hours
year = (_day and 0xC0) >> 6 '
Transform year
_day = ((_day and 0x30) >> 4)*10 + (_day and 0x0F) '
Transform day
_month = ((_month and 0x10) >> 4)*10 + (_month and 0x0F) '
Transform month
end sub
'-------------------- Output values to Lcd
sub procedure Display_Time()
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 sub
'------------------ Performs project-wide init
sub procedure 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
Lcd_Out(1,1,"Date:") ' Prepare and output static text on Lcd
Lcd_Chr(1,8,":")
Lcd_Chr(1,11,":")
Lcd_Out(2,1,"Time:")
Lcd_Chr(2,8,":")
Lcd_Chr(2,11,":")
Lcd_Out(1,12,"200")
end sub
344
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroBasic PRO for AVR
CHAPTER 6