This discussion deals with the use of the 16-bit counter (TMR1) in the PICAXE-28X, and I assume the -40X as well. This may be used to count external events in the background. One application that comes to mind is a rainfall tipping bucket counter, where the user doesn't really care to devote an entire PICAXE to this task.

Another appication might be to use the counter as a primitive indication to monitor that an event happened, again, without camping on a pin.

The X series of PICAXE devices are implemented using Microchip PICs which all include a 16-bit counter which may be externally accessed. Unfortunately, on the PICAXE-18X (PIC16F88) the T1CKI input is associated with PORTB which are fixed as output pins. However for the -28X, T1CKI is on terminal 6 which may be used as an input. Note that this is bit0 of PICAXE PortC.

The Timer1 is configured by poking register T1CON (at location $10). The clock source is selected as external by clearing the TMR1CS bit and the counter is turned on by setting TMR1ON bit.

At any time, TMR1H and TMR1L at locations $0F and $0E.

A simple routine which first clears the 16-bit counter value, pokes the T1CON register to configure the counter and then reads and displays the high and low bytes of the counter appears below.

' clock source ------------ PICAXE-28X (term 6) (T1CKI)
' copyright, Peter H Anderson, Baltimore, MD, April, '04

Symbol T1CONVal = B0
Symbol CounterH = B3
Symbol CounterL = B2
Symbol Counter = W1

     Poke $0F, 0	' clear high and low bytes of Timer1
     Poke $0E, 0

     Poke $10, $03	' Configure T1CON for Timer1 On, External Clock


     High 0
     Pause 100
     Low 0
     Peek $10, T1CONVal
     Peek $0F, CounterH
     Peek $0E, CounterL
     SerTxD (#T1CONVal, "  ", #CounterH, "  ", #CounterL, 13, 10)
     SerTxD (#Counter, 13, 10)
     Pause 1000
     GoTo Top