#include <io.h>
#include <delay.h>
#include <alcd.h>
#include <stdlib.h>
#include <stdio.h>

void main(void)
{
    unsigned char hour = 23;
    unsigned char min = 59;    
    unsigned char sec = 55;    
        
    char str[32];
    
    lcd_init(16);
    lcd_clear();
    
    lcd_puts("App started!");
    delay_ms(1000);
    lcd_clear();
    
    while(1)
    {      
        // RTC
                
        if(++sec >= 60)
        {             
            sec = 0;
            if(++min >= 60)
            {       
                min = 0;
                if(++hour >= 24)
                {              
                    hour = 0;
                }
            }
        }
    
        sprintf(str, "%02d:%02d:%02d", hour, min, sec);
        lcd_gotoxy(0,0);
        lcd_puts(str);         
        delay_ms(1000);        
    }      
}