; copyright 2003 Richard Cappels, projects@cappels.org, http://projects.cappels.org ; Half-Flying capacitor multiplexer using an AT90S1200A. ; .include "1200def.inc" .def temp = r16 .def LED1 = r17 .def LED2 = r18 .ORG $0000 rjmp start .ORG $0002 rjmp timerservice rjmp start start: ;INITIALIZATION ldi LED1,0b00000000 ;Initialize LED registers ldi LED2,0b00000000 ldi temp,0b00111101 ;Set data direction register out DDRB,temp ;LEDs and comparitor + as outputs. ldi temp,$00 ;Set state of output pins out PORTB,temp ;LEDs off,Comparitor + LOW. ldi temp, $02 ;Initaize prescaler to clock/8. out TCCR0, temp ldi temp, $02 ;Initialize TIMSK. out TIMSK,temp ldi temp,$02 ;Enable timer interrupt. out TIMSK,temp sei ;Enable interrupts. loop: ;OUTPUT TO LEDs andi LED1,0b00100000 ;If LED1 bit 5 is high, light LED1 breq noled1 sbi PORTB,4 rjmp testled2 noled1: cbi PORTB,4 testled2: andi LED2,0b00100000 ;If LED2 bit 5 is high, light LED2. breq noled2 sbi PORTB,5 rjmp ledtestdone noled2: cbi PORTB,5 ledtestdone: rjmp loop timerservice: ;TEST INPUTS AGAINST REFERENCE VOLTATGE cbi DDRB,0 ;+ Input to comparitor high Z. sbi PORTB,2 ; Input 1 pin logic high. nop ; Wait 1 microsecond for comparitor to settle. in LED1,ACSR ; Copy comparitor state to memory. cbi PORTB,2 ; Input 1 pin logic low. sbi PORTB,3 ; Input 2 pin logic high. nop ; Wait 1 micrsecond for comparitor to settle. in LED2,ACSR ; Copy comparitor state to memory. cbi PORTB,3 ; Input 2 to logic low sbi DDRB,0 ; + Input of comparitor to ground. reti ; Return from interrupt. .exit