******
** T_CTRL_1.ASM  (68HC11)
**
** Switches on I/O Box simulate reading of an A/D converter
**
** Heater (bit 0 on discrete LEDS) turns off when level above or at $3F
** Stays off until below or at $10.  Stays on until level again $3F or
** above.
**
**
** P. H. Anderson, MSU, 6 Feb 93
*******

PSCT 		EQU $C000
DSCT		EQU $D000
IDSCT		EQU $D300

REG_BASE	EQU $1000

PORTB   EQU $04
PORTC   EQU $03
DDRC    EQU $07

        ORG PSCT

	LDY #REG_BASE
        CLR DDRC,Y      * portc configured as input

	BCLR PORTB,Y %00000001	* heater turned off

GET_READING
	LDAA PORTC,Y

TST_HI_THRESH
	CMPA #$3F
	BCS TST_LO_THRESH  	* below high threshold
	BRA TURN_OFF		* otherwise too hot

TST_LO_THRESH
	CMPA #$10
	BCC GET_READING		* between high and lo thresh
	BRA TURN_ON		* otherwise too cool

TURN_ON
	BSET PORTB,Y %00000001	* set least sig bit
	BRA GET_READING

TURN_OFF
	BCLR PORTB,Y %00000001	* clear least sig bit
	BRA GET_READING

