diff options
Diffstat (limited to 'electronics/asm')
-rw-r--r-- | electronics/asm/1.asm | 2 | ||||
-rw-r--r-- | electronics/asm/\ | 45 | ||||
-rw-r--r-- | electronics/asm/final.asm | 75 | ||||
-rw-r--r-- | electronics/asm/final.err | 0 | ||||
-rw-r--r-- | electronics/asm/stack.asm | 2 | ||||
-rw-r--r-- | electronics/asm/temp.asm | 22 | ||||
-rw-r--r-- | electronics/asm/temp.ba~ | 40 | ||||
-rw-r--r-- | electronics/asm/test.asm | 69 | ||||
-rw-r--r-- | electronics/asm/test.ba~ | 53 | ||||
-rw-r--r-- | electronics/asm/test.err | 0 |
10 files changed, 238 insertions, 70 deletions
diff --git a/electronics/asm/1.asm b/electronics/asm/1.asm index 70eaa99..92a8f0d 100644 --- a/electronics/asm/1.asm +++ b/electronics/asm/1.asm @@ -13,9 +13,9 @@ main: movlw b'11111111' movwf PORTB call wait1000ms - call wait1000ms movlw b'00000000' movwf PORTB call wait1000ms goto main + END ; ends the program diff --git a/electronics/asm/\ b/electronics/asm/\ deleted file mode 100644 index c86ca8e..0000000 --- a/electronics/asm/\ +++ /dev/null @@ -1,45 +0,0 @@ -start: -init: - clrf PORTA ; make sure port A output latches are low - clrf PORTB ; make sure port B output latches are low - bsf STATUS,RP0 ; select memory bank 1 - movlw b'00000000' ; set port A data direction to inputs - movwf TRISA - movlw b'00001111' ; set port B data direction to outputs - movwf TRISB - bcf STATUS,RP0 ; select memory bank 0 - - ;stackptr EQU B10 - tmpdata EQU B9 - - goto main - -main: - ;movlw 0 - ;movwf stackptr - - movlw b'00000001' - movwf PORTA - - movlw b'10100000' ; move 1111 to the output - movwf PORTB - - movlw b'00000000' - movwf PORTA - - movlw b'11111111' - movwf TRISB - - movf PORTB, W - movwf tmpdata - - movlw b'00001111' - movwf TRISB - - swapf tmpdata, W - movwf PORTB - -noend: - goto noend - - END ; ends the program diff --git a/electronics/asm/final.asm b/electronics/asm/final.asm new file mode 100644 index 0000000..3326119 --- /dev/null +++ b/electronics/asm/final.asm @@ -0,0 +1,75 @@ +start: +init: + clrf PORTA ; make sure port A output latches are low + clrf PORTB + bsf STATUS,RP0 ; select memory bank 1 + + movlw b'11111111' ; set port A data direction to inputs + movwf TRISA + movlw b'00000000' ; set port B data direction to outputs + movwf TRISB + bcf STATUS,RP0 ; select memory bank 0 + + bsf INTCON, INT0IE + bsf INTCON, GIE + + rawtemp EQU B6 + countdown EQU B7 + + movlw 5 + movwf countdown + movlw 0 + + goto main + +interrupt: + btfss INTCON, INT0IF + retfie + + clrf PORTB + + bcf INTCON, INT0IF + bsf INTCON, GIE + bsf INTCON, INT0IE + + ; USE A TRANSITOR WITH 1K resistor to the power rail of chip + + goto start ; restarts the program + retfie + +beep: ; a for loop that beeps a buzzer and turns on a led then sets a led on + ; if nothing is done + + bcf PORTB, 3 ; turn off the status + bsf PORTB, 0 ; put a RED LED on PORTB:0 + bsf PORTB, 1 ; put a BUZZER on PORTB:1 + call wait1000ms + bcf PORTB, 0 + bcf PORTB, 1 + call wait1000ms + + decfsz countdown, F + goto beep + + bsf PORTB, 2 ; put an AMBER LED on PORTB:2 + + goto start +main: ; reads the temprature + bsf PORTB,3 ; put a GREEN LED for status on PORTB:3 + + call readadc1 ; put a THERMISTOR on PORTA:1 + movf B1, W + movwf rawtemp + + call readadc0 ; put a POT on PORTA:0 + movf B0, W + + subwf rawtemp, w ; subtract the from the threshold value + btfss STATUS, 0 ; if higher than desired temp + goto beep ; ^ + + clrf STATUS + + goto main + + END ; ends the program diff --git a/electronics/asm/final.err b/electronics/asm/final.err new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/electronics/asm/final.err diff --git a/electronics/asm/stack.asm b/electronics/asm/stack.asm index c86ca8e..5d78ada 100644 --- a/electronics/asm/stack.asm +++ b/electronics/asm/stack.asm @@ -38,8 +38,6 @@ main: swapf tmpdata, W movwf PORTB - noend: goto noend - END ; ends the program diff --git a/electronics/asm/temp.asm b/electronics/asm/temp.asm index c6d808d..353160c 100644 --- a/electronics/asm/temp.asm +++ b/electronics/asm/temp.asm @@ -12,27 +12,27 @@ init: ;bsf INTCON, INT0IE ;bsf INTCON, GIE - rawtemp EQU B5 + rawtemp EQU B6 goto main - showme: - movlw 255 - movwf PORTB - return - + movlw 255 + movwf PORTB + goto main main: - call readadc1 + call readadc1 ; read the thermistor (at room tem its 73) movf B1, W movwf rawtemp - call readadc0 + call readadc0 movf B0, W subwf rawtemp, w - - btfsc STATUS, 2 - call showme + btfsc STATUS, 0 + goto showme + + movlw 0 + movwf PORTB goto main diff --git a/electronics/asm/temp.ba~ b/electronics/asm/temp.ba~ new file mode 100644 index 0000000..d9a6889 --- /dev/null +++ b/electronics/asm/temp.ba~ @@ -0,0 +1,40 @@ +start:
+init:
+ clrf PORTA ; make sure port A output latches are low
+ clrf PORTB ; make sure port B output latches are low
+ bsf STATUS,RP0 ; select memory bank 1
+ movlw b'11111111' ; set port A data direction to inputs
+ movwf TRISA
+ movlw b'00000000' ; set port B data direction to outputs
+ movwf TRISB
+ bcf STATUS,RP0 ; select memory bank 0
+
+ ;bsf INTCON, INT0IE
+ ;bsf INTCON, GIE
+
+ rawtemp EQU B6
+
+ goto main
+showme:
+ movlw 255
+ movwf PORTB
+ goto main
+main:
+ call readadc1 ; read the thermistor (at room tem its 73)
+ movf B1, W
+ movwf rawtemp
+
+ call readadc0
+ movf B0, W
+
+ subwf rawtemp, w
+ btfsc STATUS, 0
+ goto showme
+
+ movlw 0
+ movwf PORTB
+
+ goto main
+
+ END ; ends the program
+
diff --git a/electronics/asm/test.asm b/electronics/asm/test.asm index 057bc1f..38ca537 100644 --- a/electronics/asm/test.asm +++ b/electronics/asm/test.asm @@ -1,13 +1,60 @@ start: init: - clrf PORTA ; make sure port A output latches are low - clrf PORTB ; make sure port B output latches are low - bsf STATUS,RP0 ; select memory bank 1 - movlw b'11111111' ; set port A data direction to inputs - movwf TRISA - movlw b'00000000' ; set port B data direction to outputs - movwf TRISB - bcf STATUS,RP0 ; select memory bank 0 - goto main -main: - END ; ends the program + clrf PORTA ; make sure port A output latches are low + bsf STATUS,RP0 ; select memory bank 1 + movlw b'11111111' ; set port A data direction to inputs + movwf TRISA + movlw b'00000000' ; set port B data direction to outputs + movwf TRISB + bcf STATUS,RP0 ; select memory bank 0 + + bsf INTCON, INT0IE + bsf INTCON, GIE + + rawtemp EQU B6 + countdown EQU B7 + + movlw 5 + movwf countdown + + movlw 0 + + goto main + +interrupt: + clrf PORTB ; clear PORTB + goto start ; restarts the program + +beep: ; a for loop that beeps a buzzer and turns on a led then sets a led on + ; if nothing is done + + bsf PORTB, 0 ; put a RED LED on PORTB:0 + bsf PORTB, 1 ; put a BUZZER on PORTB:1 + call wait1000ms + bcf PORTB, 0 + bcf PORTB, 1 + call wait1000ms + + decfsz countdown, F + goto beep + + bsf PORTB, 2 ; put an AMBER LED on PORTB:2 + + goto start +main: ; reads the temprature + call readadc1 ; put a THERMISTOR on PORTA:1 + movf B1, W + movwf rawtemp + + call readadc0 ; put a POT on PORTA:0 + movf B0, W + + subwf rawtemp, w ; subtract the from the threshold value + btfss STATUS, 0 ; if higher than desired temp + goto beep ; ^ + + clrf STATUS + + goto main + + END ; ends the program diff --git a/electronics/asm/test.ba~ b/electronics/asm/test.ba~ new file mode 100644 index 0000000..0d97471 --- /dev/null +++ b/electronics/asm/test.ba~ @@ -0,0 +1,53 @@ +start:
+init:
+ clrf PORTA ; make sure port A output latches are low
+ clrf PORTB ; make sure port B output latches are low
+ bsf STATUS,RP0 ; select memory bank 1
+ movlw b'11111111' ; set port A data direction to inputs
+ movwf TRISA
+ movlw b'00000000' ; set port B data direction to outputs
+ movwf TRISB
+ bcf STATUS,RP0 ; select memory bank 0
+
+ ;bsf INTCON, INT0IE
+ ;bsf INTCON, GIE
+
+ rawtemp EQU B6
+ countdown EQU B7
+
+ movlw 5
+ movwf countdown
+
+ movlw 0
+
+ goto main
+beep:
+ movlw 255
+ movwf PORTB
+ call wait1000ms
+ movlw 0
+ movwf PORTB
+ call wait1000ms
+ decfsz countdown, F
+ goto beep
+
+ goto start
+main:
+ call readadc1 ; read the thermistor (at room tem its 73)
+ movf B1, W
+ movwf rawtemp
+
+ call readadc0 ; pot for calibration
+ movf B0, W
+
+ subwf rawtemp, w
+ btfss STATUS, 0
+ goto beep
+
+ movlw 0
+ movwf PORTB
+
+ goto main
+
+ END ; ends the program
+
diff --git a/electronics/asm/test.err b/electronics/asm/test.err new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/electronics/asm/test.err |