T-Clock

Demo-application for Philips LPC2000 ARM7TDMI controller with a KS0108/KS0107-based graphics-LCD (128*64 pixels), DCF77 time-receiver and Onewire-Bus (for DS18x20-Temp.-Sensor).

GLCD Clock


The "T-Clock" (name from the "flipped" T-Shape, not from the T in Thomas ;-) ) demonstrates interfacing a Philips LPC2000-ARM7TDMI with:

The time and date are received with a DCF77-receiver-module (available i.e. from elv.de and conrad.com, ca. 10 EUR). The DCF77-signal is transmitted from a station near Frankfurt/Main, Germany and can be received all over Europe, North Africa and the Middle-East. Please visit www.ptb.de and ask google with "DCF77" for more information. In times when the DCF77-signal is not available (i.e. thunder and lightning near transmitter) the RTC of the LPC-controller is used to drive the clock.

A temperature-sensor from the DS18x20 family by Maxim/Dallas is used. The sensors provide the temperature in digital form on a One-Wire-Bus. The Maxim Web-Site has a lot of information on the One-Wire-Bus.

"Human-Interface" is a 128 by 64 dots graphics LCD with a KS0107/KS0108 combi, an (mechanical rotary) encoder and a single button ("enter"). Brightness and contrast of the GLCD are controlled by software (PWM) with an OP-AMP-based amplifier and inverter circuit. If your GLCD does not provide negative voltage (VEE pin) you may have to use a extra "charge-pump-IC" or a "spare TX" of a MAX232 to get a negative contrast voltage and negative supply for the OP-AMPs.

The current time/date and some One-Wire debug messages are sent via UART0.

The hardware is designed as a "daughter-board" connected to the LPC-P1 development-board from Olimex (*). The button on the LPC-P1 is used as "enter"-key and the on-board LED serves as "heartbeat/I'm alive-sign". The Olimex board provides the LPC current-supplies and the RS232 level- shifter too.

The implementation has been done using WinARM (gcc 3.4.2 and tools). A lot of free information available from the Internet and some code from others has been used and adapted to this ARM7TDMI-S project. See comments in main.c and the device-drivers-code. I have also adapted some of my own AVR developments. Source-code overview and pin-connection are given further down on this page and in the readme.txt. If you think any copyrights have been violated please send an e-mail an I will remove this project from the web-space.

Credits and "Thank you" to:

And of couse "Thank you" to the unknown writers of various datasheets and application notes.

Well, you could buy a radio-controlled clock for about 10 EUR everywhere - but this ~60MHz 32bit clock has a much higher "geek-factor" (and a blue LCD) ... at a total cost of around 100EUR :-( . I've made it to get at least something usefull from the countless hours I've spent learning how things have to be done with the ARM7-architecture and how to interface the used pheriphery.

Changelog

Hardware

Parts

Picture Gallery

Schematic

T-Clock Schematic small
[Enlarge]

A picture or a sketch of the add-on board schematic is in the picture gallery. A schematic of the base-board can be found on www.olimex.com/dev.

The GLCD input-pins are driven directly from the LPC2106. So "logic high" is 3.3V which is below V_IH=3.5V of the used display. But the setup works reliably here since several month. If your display needs higher voltages to detect "logic high" you may simply use pull-up resistors (typ. 10kOhm) in the data- and control-input-lines and change the code (glcd.c) to drive the LPC-pins as "open-drain" (High: port-pin as input, Low: port-pins as output 0/low)

Software

Files-Overview:
LPC-2106-*.ld   - linker-scripts for Philips LPC2106 (adapted for IAP/config)
LPC2*.h         - register definitions 
crt0.S          - startup-code
armVIC          - helper-functions for the VIC 
lpc*.h          - headers
types.h         - integer types (uint8_t, uint32_t etc.)

Makefile        - makefile based on the WinARM makefile-template
config          - basic controller configuration (clock, deviders etc.)
buttons         - button/switch with debouncing (LPC-P1 (*) on-board button)
crc8            - CRC8 for the One-Wire interface
delay           - precise delays for One-Wire interface
demopic         - byte-pattern (Bitmap) of a Picture
dfc77           - driver for DFC77 receiver-module
DS18x20         - driver for Maxim/Dallas One-Wire temperature-sensors
encoder         - driver for rotary encoder
fonts           - font patterns
glcd            - driver for graphics LCD (KS0107/KS0108)
glcdctrl        - GLCD contrast and brightness control (PWM)
iap             - handling of "persistant" values (IAP "eeprom-emulation")
iap_asm.S       - assembler-helper for IAP-functions
main            - basic setup and main-loop. time/date/temp to GLCD-code
menu            - menu state-machine code and "widgets" like slider
mtutil          - some handy utility functions
onewire         - driver for the One-Wire bus
sysTime         - system-time (heartbeat/pause)
timer0          - interface to LPC hardware-timer 0
timestamp       - time-stamp structure
RTC             - driver for the LPC Real-Time-Clock
uart            - driver for the LPC UART0/1
Pin-Connections:
P0.0    LPC-P1 demo-board Uart0 RX (uart.h, lpcUART.h)
P0.1	LPC-P1 demo-board Uart0 RX (uart.h, lpcUART.h)
P0.4	OneWire-Bus (DS18x20) (onewire.h)
P0.5	Encoder Channel B (encoder.h)
P0.6	Encoder Channel A (encoder.h)
P0.7	LPC-P1 board LED (config.h)
P0.8	GLCD contrast-PWM (glcdctrl.h)
P0.9	GLCD brightness PWM (glcdctrl.h)
P0.11	GLCD Enable (glcd.h)
P0.12	GLCD Instr./Data (glcd.h)
P0.13	GLCD Read/Write (glcd.h)
P0.15	GLCD CS2 (glcd.h)
P0.16	GLCD CS1 (glcd.h)
P0.22-
P0.29   GLCD Data-Bus (flipped! see glcd.h)
P0.30	DCF77 receiver (dcf.h)
P0.31	LPC-P1 board button (config.h) (*)
IRQ/VIC-Vectors:
0+1		UART0/1 (uart.c)
2		TIMER0 (timer0.c)

Download source-archive of V 0.8 (Timestamp 20041129, Hexfile for LPC2106 at FOSC=14,7 MHz included).
The code is for LPC210x in ARM-Mode and with "executable" in flash-memory. This code has not been tested in RAM (debugging) or in Thumb-Mode. If parts of this source-code are useful for you and save you some time in a commercial project you may think about sharing a tiny part of your profit. Please send comments, suggestions and bug reports to the e-mail address given at the end of this page - Thank you.

(*) Olimex no longer sells the LPC-P1 board. It has been replaced with the LPC-P2106 on which the on-board button is connected to a different pin. Schematics for both boards are available from the Olimex website.



back to my ARM projects page


Martin Thomas


97892 hits since November 15, 2004
Last mod.: Friday, 12-May-2006 22:17:12 CEST