I have been building clocks for a while and have sometried and tested code which works great on an 18F25k22. I need to add some more features to the device which uses this so I am stepping up to the 18f26k22 just for the larger memory.

When i run the code which worked on the 18f25k22 on the 18f26k22, the clock increments randomly by 2 seconds when it should only increment by 1.

I have a 32.768kHz on the secondary oscillator input pins (with suitable caps)
Using timer 3, no prescaler and prelaod of 128 in TMR3H each epoch.

An interrupt is generated every 1 second when timer 3 rolls over and my code simply increments the 'Seconds' register...when that reaches 60 it is reset and minutes is incremented and so on.

The code has been perfectly behaved on the 25k22, but now, compiled for the 26k22 the seconds counter is sometimes incremented by 2 when it should only increment by 1

I have tried adding new variable for seconds called Seconds2 ( in case it was a memory location issue. I have tried stopping the timer3 from running, T3CON.0 = 0, before writing to it. I have tried everything I can think of, but I can't seem to get it to behave with the 26k22.

I have several boards of identical circuits, whichever has the 26k22 chip has the problem and the fault moves with the chips. I have had this with a batch of SDIP 26k22's and a couple of SOIC 26k22's

I've looked at the .inc files (Pbasic and Mchip's own) and can't see any reason for a difference between these devices, so now I am stuck, is it a Pbasic issue or a MPASM issue ? The only difference between these two chips is that the 26k22 gains 32k more memory over the 25k22, otherwise they seem to be identical.

Has anyone got any experience with something as odd as this ? For comparisons I've used CPFSEQ and CPFSGT instead of the longhand XORLW too, but nothing makes an difference. It is almost as if with the 26k22 version the TMR3 overflow isn't interrupt isn't being cleared and the code is run through twice, but I am clearing the interrupt and reloading the TMR3 registers manually.


Chris

Code:
        
btfss   PIR2,1   ; timer 3 rollover interrupt ? (1 second epoch)
        bra     INT_OUT
        bsf     _power
        btfss   PORTA,0
        bcf     _power
        bcf     T3CON,0  ; stop TMR3 prior to writing to it
        movlw   128
        movwf   TMR3H
        movf    _timer3l_buffer,w  ; compensation value for low voltage
        btfss   STATUS,Z
        movwf   TMR3L
        bsf     T3CON,0   ; re enable TMR3 after writing     
        bsf     _control,6 ; set 1 sec flag
        bcf     PIR2,1  ;clear interrupt
        incf    _seconds2,f
        movlw   60
        xorwf  _seconds2,w
        btfss   STATUS,Z
        bra     INT_OUT
        clrf    _seconds2
        incf    _Minutes,f
        movlw   60
        xorwf  _Minutes,w
        btfss   STATUS,Z
        bra     INT_OUT
        clrf    _Minutes
        incf    _Hours,f
        movlw   24
        xorwf  _Hours ,w
        btfss   STATUS,Z
        BRA     INT_OUT
        clrf    _Hours
        bsf     _control,2 ; set 'NEW DAY' flag