Quote Originally Posted by T.Jackson;38524.

Anyhow, turning your attention back to the clock for a moment, if you take a look at the schematic below you'll see that the whole thing can be built for less than the cost of your lunch. The circuit relies on no dedicated RTC chip, but instead uses portions of Paul R. Borgmeier's EZCLOCK2 code which makes good use of TMR0 to enable for some relatively accurate time keeping. Arguably almost on par with the DS1302. Last but not least, some of you may be asking what's the buzzer and LED for? Well, as it stands with the software "as is", the buzzer briefly goes off every second making a sort of tick-tock sound.

Happy time keeping [B
![/B]
<hr/>
Trent Jackson
<br/>
Trent, first of all let me say you did an awesome job on this project.
I am trying to port it over to a PIC 18F4550. My code (shown below) compiles and assembles OK, but when I turn on the PIC with the WINDOWS Clock HID running, set the clock time in the WINDOWS HID, and then turn on the COM2 port, nothing happens. The time display never changes. Nor do I see the Test LED blink.
Can you please look at my code and advise me if you see where I may have gone wrong.

Code:
'****************************************************************
'*  Name    : VClock_18F4550.BAS                                *
'*  Author  : John R. Ellis                                     *
'*  Notice  :                                                   *
'*          : A                                                 *
'*  Date    : 11/9/2009                                         *
'*  Version : 1.0                                               *
'*  Notes   : Portions of Program extracted from:               *
'*             1) EZCLOCK2 By Paul R. Borgmeier, PhD            *
'*             Crux analysis & design, LLC www.cruxanalysis.com *
'*             2) VClock by Trent Jackson (see reference below) *
'*  Device  : Options of 18F2550/4550                           *
'*  Memory  : 1624 bytes of Program Memory required             * 
'*          :                                                   *
'****************************************************************
     '*   Name    : VClock.BAS                                  *
     '*   Author  : Trent Jackson                               *
     '*   Notice  : No Copyright                                *
     '*           :                                             *
     '*   Date    : 17/5/2007                                   *
     '*   Version : 1.0                                         *
     '*                                                         *
     '* Acknowledgements                                        *
     '* Portions of Program extracted from:                     *
     '*       EZCLOCK2 By Paul R. Borgmeier, PhD                *
     '*       Crux analysis & design, LLC www.cruxanalysis.com  * 
     '***********************************************************
;--- if you un-comment these, you must comment the ones in the .inc file ---
ASM  ; setup for 18F2550/4550, 8mhz crystal used in EasyPic6..4 MHz PLL input
   __CONFIG    _CONFIG1L, _PLLDIV_2_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
   __CONFIG    _CONFIG1H, _FOSC_HSPLL_HS_1H
   __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
   __CONFIG    _CONFIG3H, _PBADEN_OFF_3H
   __CONFIG    _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L & _VREGEN_ON_2L
   __CONFIG    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
ENDASM
;ASM  ; setup for 18F13K50/14K50...Only 12mhz crystal can be used for USB
;    __CONFIG    _CONFIG1L, _CPUDIV_NOCLKDIV_1L & _USBDIV_OFF_1L
;    __CONFIG    _CONFIG1H, _FOSC_HS_1H & _PLLEN_ON_1H & _PCLKEN_ON_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
;ENDASM

   Include "modedefs.bas"             ' Serial Protocol
   Define   OSC 4                     ' EasyPic6 is 8MHz crystal; 4MHz used
'PIC: 18F4550 pin usage
' Pin 1 (RE3)  : (MCLR Internal)
' Pin 25 (TX)  : Tx pin for Serial interface
' Pin 26 (RX)  : Rx pin for Serial interface
' Pin 13 (OSC1): XTAL 8.0000 Hz (w/tolerance = 30 ppm) w/ cap to GND
' Pin 14 (OSC2): XTAL 8.0000 Hz (w/tolerance = 30 ppm) w/ cap to GND
' Pin 27 (RD4) :  Turn Something On (relay, FET, alarm, etc)
' Pin 28 (RD5) :  Test Location LED, Buzzer, VOM, nothing?                                       '
   '// Variables
   Counter    VAR Word                ' Track TMRO  
   Hours      VAR Byte                ' Total hrs (0-23)
   Minutes    VAR ByTE                ' Mins (0-59)
   Seconds    VAR Byte                ' Secs (0-59)
   RX_To_PC   VAR PORTC.7             ' RX line to Pin 26 (RC7)
   TX_To_PC   VAR PORTC.5             ' TX line to Pin 25 (RC6)
   LED_Buzzer VAR PORTB.5             ' LED & Buzzer
   
   '// Init
   CMCON    = 7                    ' All digital
   T0CON    = %10000111            ' TMR0 enabled, TMRO prescale = 256
   TRISA    = %00000000            ' All outputs
   TRISB    = %00000000            ' All outputs
   TRISC    = %01000000            ' All outputs except RC7
   INTCON.2 = 0                    ' Clear TMRO overflow flag
   Hours    = 0                    ' Null  
   Minutes  = 0                    ' ^
   Seconds  = 0                    ' ^
   Counter  = $7A12                ' Load time counter
   
   '=============
   Wait_For_TMR0:                     ' Main loop  
   '=============
   IF INTCON.2 = 0 THEN Wait_For_TMR0 ' Wait for TMRO overflow
   INTCON.2    = 0                    ' Clear TMRO overflow flag
       Counter = Counter - $800       ' Dec counter until 1 sec has elapsed  

   '// Process hrs, mins secs accordingly ...
   IF Counter < $800 THEN
      Seconds = Seconds + 1
      If Seconds = 60 Then
         Seconds = 0
         Minutes = Minutes + 1
         If Minutes = 60 Then
            Minutes = 0
            Hours = Hours + 1
            If Hours = 24 Then
               Hours = 0
            EndIf
         EndIf
      EndIf
   
   '// Add leading zeros to all single digits & output str serially to PC
      If Hours < 10 And Minutes > 9 And Seconds > 9 Then
         SEROUT RX_To_PC, N2400, ["@","0",#Hours,":",#Minutes,":",#Seconds]
      ELSE
          IF Hours > 9 and Minutes < 10 and Seconds > 9 THEN
             SEROUT RX_To_PC, N2400, ["@",#Hours,":0",#Minutes,":",#Seconds]
      ELSE
          IF Hours < 10 and Minutes < 10 and Seconds > 9 THEN
             SEROUT RX_To_PC, N2400, ["@","0",#Hours,":0",#Minutes,":",#Seconds]
      ELSE
          IF Hours > 9 and Minutes > 9 and Seconds < 10 THEN
             SEROUT RX_To_PC, N2400, ["@",#Hours,":",#Minutes,":0",#Seconds]
      ELSE
          IF Hours < 10 and Minutes > 9 and Seconds < 10 THEN
             SEROUT RX_To_PC, N2400, ["@","0",#Hours,":",#Minutes,":0",#Seconds]
      ELSE
          IF Hours > 9 and Minutes < 10 and Seconds < 10 THEN
             SEROUT RX_To_PC, N2400, ["@",#Hours,":0",#Minutes,":0",#Seconds]
      ELSE
          IF Hours < 10 and Minutes < 10 and Seconds < 10 THEN
             SEROUT RX_To_PC, N2400, ["@","0",#Hours,":0",#Minutes,":0",#Seconds]
      Else
         SEROUT RX_To_PC, N2400, ["@",#Hours,":",#Minutes,":",#Seconds]
      EndIf : EndIf : EndIf : EndIf : EndIf : EndIf : EndIf

      Counter = Counter + $7A12          ' Reset counter 
      Toggle LED_Buzzer                  '  
   '//
   Else 'Wait here for 50mS to see if the host(PC) is trying to set new time val                               
   '//
      SERIN TX_To_PC, N2400, 50, Wait_For_TMR0, ["@"], Hours, Minutes, Seconds
   EndIf
   GoTo Wait_For_TMR0                    ' Loop back
   end