@denkimono facebook.com/denkimono

# Programming the timer

Overview | In the Media | Ordering | Construction | Programming | User mods
The PIC that controls the timer can be reprogrammed either in an external programmer or in-circuit using the connections available from CN6. This allows you to add your own functionality to the timer or use the hardware as a platform for your own projects.
Alternate software for the platform can be found on the 'Mods' page. If you have a mod you'd like to share with the world then drop us an email!

### Source code

The zip file contains the following files:

> alarm.asm - alarm setting functions
> clock.asm - clock setting functions
> countdown.asm - count up/down setting functions
> delay.asm - delay functions
> display.asm - handle the display for each mode
> initialise.asm - initialise the hardware and variables
> interrupts.asm - interrupt handler: 100Hz events, make alarm noises
> keyboard.asm - scan keyboard, validate time and alarm values
> maths.asm - multiplication and division routines
> multiplexer.asm - display multiplexer, called by 100Hz interrupt
> tables.asm - keycodes, LED bit patterns, time/alarm maximum digit values
> timer.asm - main asm file, main program loop, vectors
> macros.inc - some useful macros
> system.inc - system config flags, RAM variables, constants, pin definitions
> timer.hex - compiled HEX file

Just compile 'timer.asm' and the other files are included with it.
v2.11 source code for boards with S8050 transistors
v2.2 source code for boards with generic PNP transistors

### Compiling the code

The following development environments are available for free. They will allow you to build the source code and produce a .hex file that can be loaded onto the PIC microcontroller.

For Windows: | Microchip MPLAB
For Linux: | GPUTILS

### Programming

The PIC can be removed from its socket for programming, alternatively it can be programmed in-circuit via connector CN6. In-circuit programming is much faster than having to remove the PIC from its socket each time, and also reduces the risk of damage to the PIC and the socket by repeated extraction and insertion. The connector provides direct connections to the PIC programming pins with no diodes to isolate it from the rest of the circuit (see the schematic) so it may not be suitable for all programmers. To choose a programmer, a Google search will turn up many commercial and DIY programmers for the PIC16F72. As an example, this range of programmers from Quasar Electronics in the UK are suitable.
I made a simple plug and socket for my timer and programmer out of a SIL socket strip. These plug in to themselves allowing me to make a plug for my programmer (a Quasar 3149) to connect directly to the board. Here's an example of a programming connection to the timer:

SIL socket | SIL socket mounted on the board | The SIL sockets connect with themselves so can be used to create a plug for the programmer

The final in-circuit programming setup.

### Debugging

Debugging embedded software in assembly language with no ICE is challenging and a lot of fun. Best of luck :)

### Adding hardware

Connector CN5 gives access to the PIC's port B lines 1 to 7 and the board power supply for additional hardware. These lines are shared with the keypad so you can either remove it or employ cunning design to have the keypad work side by side with your killer app.