; ----------------------------------------------------------------------- ; Microcontroller Makes Linear Temperature Measurement Simple ; Author: Bonifacio Martin-del-Brio & Nicolas Medrano-Marques ; Dept. Ingenieria Electronica y Comunicaciones ; Universidad de Zaragoza, Zaragoza, Spain; ; ----------------------------------------------------------------------- ; A/D and voltage-to-temperature conversion routine ; written for 68HC11 ; Result: temperature in deg C in accumulator B ; ----------------------------------------------------------------------- ; A/D conversion (the A/D must be enabled in RESET routine) LDAA #1 ; single channel conversion (PE1 pin) STAA $1030 ; ADCTL register, starts conversion loopl LDAA $1030 ; BPL loop1 ; A/D complete when ADCTL[7]=1 LDAA $1031 ; digital (hex) value of the input voltage ; Voltage to temperature (?C) conversion (in B accumulator) LDAB #17 ; MUL ; AxB=>D (17 x hex); 8x8 => 16-bits LDX #50 ; IDIV ; D/X, quotient in X, remainder in D ; (21 x hex /50) XGDX ; X<=>D, value in B register SUBB #18 ; temperature in B register ; (17 x hex/50-18) ; -----------------------------------------------------------------------