H_keeping:
beep ;beep has to be incorporated into scan routine it cannot take up extra time as this will
;change the flash-rate
;bsf buz ; piezo on
;movlw .170
;movwf buz_file
;decfsz buz_file,F
;goto $-1
;bcf buz ; piezo off
;movlw .170
;movwf buz_file
;decfsz buz_file,F
;goto $-1
;bcf buz ; piezo off
;decf buz_length,F
; Leds:
; 7 6 5 4 3 2 1 0
; blink onoff up down light toast time temp
btfss leds_s,7 ; Is led blink enabled?
goto contled ; notenabled ; No, get out!
btfsc leds_s,6 ; Is led on/off on?
goto $+3
bcf LED_ONOFF ; No - it's activated directly, not using LED_CMN
goto $+2
bsf LED_ONOFF ; Yes - it's activated directly, not using LED_CMN
;notenabled:
decfsz Led_blink,F ; Blink control = 0?
goto contled ; No
movlw D'255' ; Value to preload to
movwf Led_blink ; Led blink time control
btfsc leds_s,6 ; Is led on/off on?
goto setledoff
bsf leds_s,6 ; Led on/off in on
goto contled
setledoff:
bcf leds_s,6 ; Led on/off in off
contled:
btfss LEDS_ON
goto endleds
btfsc leds_s,5 ; Is led up on?
goto $+3
bsf LED_UP ; No
goto $+2
bcf LED_UP ; Yes
btfsc leds_s,4 ; Is led down on?
goto $+3
bsf LED_DWN ; No
goto $+2
bcf LED_DWN ; Yes
btfsc leds_s,3 ; Is led light on?
goto $+3
bsf LED_LIGHT ; No
goto $+2
bcf LED_LIGHT ; Yes
btfsc leds_s,2 ; Is led toast on?
goto $+3
bsf LED_TOASTER ; No
goto $+2
bcf LED_TOASTER ; Yes
btfsc leds_s,1 ; Is led time on?
goto $+3
bsf LED_timer ; No
goto $+2
bcf LED_timer ; Yes
btfsc leds_s,0 ; Is led temp on?
goto $+3
bsf LED_TEMP ; No
goto $+2
bcf LED_TEMP ; YES
endleds:
bcf LEDS_ON
; Test_Keys (k_pressed):
; 7 6 5 4 3 2 1 0
; X up timer onoff light toast temp down
bsf STATUS,RP0 ; Bank 1
;bcf STATUS,RP1 ; " "
bcf OPTION_REG,NOT_RABPU ; Activate pull-up resistors - Clear RABPU flag
movlw B'00111100' ;
movwf TRISA ; Make RA2, RA4, RA3 and RA5 inputs (RA3 is a sensor)
movlw B'11110000' ;
movwf TRISB ; Make RB4, RB5, RB6 and RB7 inputs
movlw B'00110100' ;
movwf WPUA ; Enable RA2, RA4 and RA5 pull-up internal resistors
movlw B'11110000'
movwf WPUB ; Enable RB4, RB5, RB6 and RB7 pull-up internal resistors
bsf OPTION_REG,7 ; Set RABPU flag
;bcf STATUS,RP0 ; Bank 2
;bsf STATUS,RP1 ; " "
;
;bsf STATUS,RP0 ; Bank 1
;bcf STATUS,RP1 ;
bcf STATUS,RP0 ; Bank 0
;bcf STATUS,RP1 ;
btfss KEY_UP ; KEY_UP pressed?
incf temper,F ; Yes
btfsc KEY_UP ; Key Up pressed?
goto $+3 ; No
bsf k_pressed,6 ; Yes, set flag
goto $+2 ; Exit
bcf k_pressed,6 ; No, reset flag
btfsc KEY_timer ;
goto $+3 ;
bsf k_pressed,5 ;
goto $+2 ;
bcf k_pressed,5 ;
btfsc KEY_ONOFF ;
goto $+3 ;
bsf k_pressed,4 ;
goto $+2 ;
bcf k_pressed,4 ;
btfsc KEY_LIGHT ;
goto $+3 ;
bsf k_pressed,3 ;
goto $+2 ;
bcf k_pressed,3 ;
btfsc KEY_TOASTER ;
goto $+3 ;
bsf k_pressed,2 ;
goto $+2 ;
bcf k_pressed,2 ;
btfsc KEY_TEMP ;
goto $+3 ;
bsf k_pressed,1 ;
goto $+2 ;
bcf k_pressed,1 ;
btfsc KEY_DWN ;
goto $+3 ;
bsf k_pressed,0 ;
goto $+2 ;
bcf k_pressed,0 ;
bsf STATUS,RP0 ; Bank 1
;bcf STATUS,RP1 ;
;movlw B'00000000' why do you want to set and clear the weak pullups??
bcf WPUA,7
;bcf STATUS,RP0 ; Bank 2
;bsf STATUS,RP1 ;
;movlw B'00000000'
bcf WPUB,7
;bsf STATUS,RP0 ; Bank 1
;bcf STATUS,RP1 ;
bcf OPTION_REG,7 ; Set RABPU flag
movlw B'00001000' ;
movwf TRISA ;
movlw B'00000000' ;
movwf TRISB ;
bcf STATUS,RP0 ; Bank 0
;bcf STATUS,RP1 ;
retlw 00