test.asm (1268B)
1 start: 2 init: 3 clrf PORTA ; make sure port A output latches are low 4 bsf STATUS,RP0 ; select memory bank 1 5 movlw b'11111111' ; set port A data direction to inputs 6 movwf TRISA 7 movlw b'00000000' ; set port B data direction to outputs 8 movwf TRISB 9 bcf STATUS,RP0 ; select memory bank 0 10 11 bsf INTCON, INT0IE 12 bsf INTCON, GIE 13 14 rawtemp EQU B6 15 countdown EQU B7 16 17 movlw 5 18 movwf countdown 19 20 movlw 0 21 22 goto main 23 24 interrupt: 25 clrf PORTB ; clear PORTB 26 goto start ; restarts the program 27 28 beep: ; a for loop that beeps a buzzer and turns on a led then sets a led on 29 ; if nothing is done 30 31 bsf PORTB, 0 ; put a RED LED on PORTB:0 32 bsf PORTB, 1 ; put a BUZZER on PORTB:1 33 call wait1000ms 34 bcf PORTB, 0 35 bcf PORTB, 1 36 call wait1000ms 37 38 decfsz countdown, F 39 goto beep 40 41 bsf PORTB, 2 ; put an AMBER LED on PORTB:2 42 43 goto start 44 main: ; reads the temprature 45 call readadc1 ; put a THERMISTOR on PORTA:1 46 movf B1, W 47 movwf rawtemp 48 49 call readadc0 ; put a POT on PORTA:0 50 movf B0, W 51 52 subwf rawtemp, w ; subtract the from the threshold value 53 btfss STATUS, 0 ; if higher than desired temp 54 goto beep ; ^ 55 56 clrf STATUS 57 58 goto main 59 60 END ; ends the program