MAIN_LOOP:
movf TEMPER,W ; Put temperature in W
call BIN2BCD ; Decode Temperature to bcd
bsf LED_CMN ; Leds off
movf UNITS,W ; copy units to W
call DECDISP_A ; convert
movwf PORTA ; put it in PORTA
movf UNITS,W ; copy units to W
call DECDISP_B ; convert
movwf PORTB ; put it in PORTA
bcf DISP1 ; display 1 on
call H_keeping ; delay 2 ms
movf TENS,W ; copy tens to W
call DECDISP_A ; convert
bsf DISP1 ; display 1 off
movwf PORTA ; put it in PORTA
movf TENS,W ; copy tens to W
call DECDISP_B ; convert
movwf PORTB ; put it in PORTA
bcf DISP2 ; display 2 on
call H_keeping ; delay 2 ms
movf HUNDREDS,W ; copy hundeds to W
call DECDISP_A ; convert
bsf DISP2 ; display 2 off
movwf PORTA ; put it in PORTA
movf HUNDREDS,W ; copy hundeds to W
call DECDISP_B ; convert
movwf PORTB ; put it in PORTA
bcf DISP3 ; display 3 on
call H_keeping ; delay 2 ms
bsf DISP3 ; display 3 off
; Leds code:
bcf LED_CMN ; Leds on
call H_keeping ; delay 2 ms
bsf LED_CMN ; Leds off
goto MAIN_LOOP ; Back to main loop
H_keeping:
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
; X onoff up down light toast time temp
btfsc leds_s,7 ; Is led blink enabled?
goto 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:
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
retlw 00
FLAGS EQU 0x2B ; General use flags
#define LEDS_ON FLAGS,0 ; Flag o see if the leds should be on
H_keeping:
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
; X onoff up down light toast time temp
btfsc leds_s,7 ; Is led blink enabled?
goto 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
bcf LEDS_ON ; turn leds flag off
endleds:
retlw 00
MAIN_LOOP:
movf TEMPER,W ; Put temperature in W
call BIN2BCD ; Decode Temperature to bcd
movf UNITS,W ; copy units to W
call DECDISP_A ; convert
bsf LED_CMN ; Leds off
movwf PORTA ; put it in PORTA
movf UNITS,W ; copy units to W
call DECDISP_B ; convert
movwf PORTB ; put it in PORTA
bcf DISP1 ; display 1 on
call H_keeping ; delay 2 ms
movf TENS,W ; copy tens to W
call DECDISP_A ; convert
bsf DISP1 ; display 1 off
movwf PORTA ; put it in PORTA
movf TENS,W ; copy tens to W
call DECDISP_B ; convert
movwf PORTB ; put it in PORTA
bcf DISP2 ; display 2 on
call H_keeping ; delay 2 ms
movf HUNDREDS,W ; copy hundeds to W
call DECDISP_A ; convert
bsf DISP2 ; display 2 off
movwf PORTA ; put it in PORTA
movf HUNDREDS,W ; copy hundeds to W
call DECDISP_B ; convert
movwf PORTB ; put it in PORTA
bcf DISP3 ; display 3 on
call H_keeping ; delay 2 ms
bsf DISP3 ; display 3 off
; Leds code:
bsf LEDS_ON ; Flag leds on
bcf LED_CMN ; Leds on
call H_keeping ; delay 2 ms
goto MAIN_LOOP ; Back to main loop
H_keeping:
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:
; Test_Keys (keys_s):
; 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
bcf STATUS,RP0 ; Bank 2
bsf STATUS,RP1 ; " "
movlw B'11110000' ;
movwf WPUB ; Enable RB4, RB5, RB6 and RB7 pull-up internal resistors
bcf STATUS,RP0 ; Bank 0
bcf STATUS,RP1 ; " "
; Here start the code to test the keys
btfsc KEY_UP ; Key Up pressed?
goto $+3 ; No
bsf keys_s,6 ; Yes, set flag
goto $+2 ; Exit
bcf keys_s,6 ; No, reset flag
btfsc KEY_TIMER ;
goto $+3 ;
bsf keys_s,5 ;
goto $+2 ;
bcf keys_s,5 ;
btfsc KEY_ONOFF ;
goto $+3 ;
bsf keys_s,4 ;
goto $+2 ;
bcf keys_s,4 ;
btfsc KEY_LIGHT ;
goto $+3 ;
bsf keys_s,3 ;
goto $+2 ;
bcf keys_s,3 ;
btfsc KEY_TOASTER ;
goto $+3 ;
bsf keys_s,2 ;
goto $+2 ;
bcf keys_s,2 ;
btfsc KEY_TEMP ;
goto $+3 ;
bsf keys_s,1 ;
goto $+2 ;
bcf keys_s,1 ;
btfsc KEY_DWN ;
goto $+3 ;
bsf keys_s,0 ;
goto $+2 ;
bcf keys_s,0 ;
btfss KEY_UP
incf TEMPER,F
;btfsc KEY_UP ; KEY_UP pressed?
;goto nextkey ; No, process next key
;up_pressed:
;btfss leds_s,7 ; blink set?
;goto setblink ; No, turn it on!
;bcf leds_s,7 ; Yes, turn it off!
;goto nextkey ; Continue with next key
;setblink:
;bsf leds_s,7 ; Turn blink on
;nextkey:
; Continue to test the keys...
; ..........
; Here, the code to test the keys ends.
;contkey:
bsf STATUS,RP0 ; Bank 1
bcf STATUS,RP1 ; " "
bsf OPTION_REG,NOT_RABPU; Deactivate pull-up resistors - Set RABPU flag
movlw B'00001000' ; All PORTA pins outputs, but RA3
movwf TRISA ;
movlw B'00000000' ; All PORTB pins outputs
movwf TRISB ;
bcf STATUS,RP0 ; Back to Bank 0
bcf STATUS,RP1 ; " " "
retlw 00
;/****************************************************************************
;* DESCRIPTION: System definitions.
;*****************************************************************************/
ERRORLEVEL -302 ;remove message about using proper bank
LIST P=16F677
INCLUDE <P16F677.INC>
__CONFIG _BOR_OFF & _FCMEN_OFF & _IESO_OFF & _CPD_OFF & _CP_OFF & _MCLRE_OFF & _PWRTE_ON & _WDT_OFF & _INTOSCIO
keys_s EQU 0x20 ; Keys pressed state
; Displays
#define DISP1 PORTC,3 ; Anode display DIS0
#define DISP2 PORTC,4 ; Anode display DIS1
#define DISP3 PORTC,5 ; Anode display DIS2
; Leds
#define LED_CMN PORTC,2 ; Leds Anodes
ORG 0x0000
goto START
;==============================================
START:
bcf STATUS,RP0 ; Bank 2
bsf STATUS,RP1 ;
clrf ANSEL ; digital I/O
clrf ANSELH ; " " "
movlw B'00000000'
movwf CM1CON0 ; disable comparator
movlw B'00000000' ; Not necessary?
movwf CM2CON0 ; disable 2nd comparator
movlw B'00000000' ; Not necessary?
movwf CM2CON1 ; disable 3rd comparator
bsf STATUS,RP0 ; Bank 1
bcf STATUS,RP1 ;
movlw B'00001000' ;
movwf TRISA ;
movlw B'00000000' ;
movwf TRISB ;
movlw B'10000010' ;
movwf TRISC ;
bcf STATUS,RP0 ; Bank 0
bcf STATUS,RP1 ;
bcf SSPCON,SSPEN ; Disable Synchronous Serial Port
; Turn off all displays and leds
bsf LED_CMN ; Leds off
bsf DISP1 ; Display1 off
bsf DISP2 ; Display2 off
bsf DISP3 ; Display3 off
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
bcf STATUS,RP0 ; Bank 2
bsf STATUS,RP1 ; " "
movlw B'11110000' ;
movwf WPUB ; Enable RB4, RB5, RB6 and RB7 pull-up internal resistors
bcf STATUS,RP0 ; Bank 0
bcf STATUS,RP1 ; " "
; Here start the code to test the keys
btfsc PORTB,7 ; Key Up pressed?
goto $+3 ; No
bsf keys_s,6 ; Yes, set flag
goto $+2 ; Exit
bcf keys_s,6 ; No, reset flag
btfsc PORTB,6 ;
goto $+3 ;
bsf keys_s,5 ;
goto $+2 ;
bcf keys_s,5 ;
btfsc PORTB,5 ;
goto $+3 ;
bsf keys_s,4 ;
goto $+2 ;
bcf keys_s,4 ;
goto $
bsf STATUS,RP0 ; Bank 1
bcf STATUS,RP1 ; " "
bsf OPTION_REG,NOT_RABPU; Deactivate pull-up resistors - Set RABPU flag
movlw B'00001000' ; All PORTA pins outputs, but RA3
movwf TRISA ;
movlw B'00000000' ; All PORTB pins outputs
movwf TRISB ;
bcf STATUS,RP0 ; Back to Bank 0
bcf STATUS,RP1 ; " " "
goto START
END
ERRORLEVEL -302 ;remove message about using proper bank
LIST P=16F677
INCLUDE <P16F677.INC>
__CONFIG _BOR_OFF & _FCMEN_OFF & _IESO_OFF & _CPD_OFF & _CP_OFF & _MCLRE_OFF & _PWRTE_ON & _WDT_OFF & _INTOSCIO
dcount EQU 0x21
portatmp EQU 0x22
portbtmp EQU 0x23
ORG 0x0000
goto START
START:
bsf STATUS,RP0 ; Bank 1
bcf STATUS,RP1 ;
movlw B'10111111' ;
movwf TRISB ; PORTB,6 output (led)
movlw B'11000011' ;
movwf TRISC ; PORTC,2,3,4,5 output (leds & displays enable)
movlw B'10000000' ;
movwf TRISB ; Make RB7 input
bcf STATUS,RP0 ; Bank 0
bcf STATUS,RP1 ; " "
movlw D'255'
movwf PORTB
movlw D'255'
movwf PORTA
movlw B'11111111'
movwf PORTC
bcf STATUS,RP0 ; Bank 2
bsf STATUS,RP1 ; " "
movlw B'11110000' ;
movwf WPUB ; Enable all portb pull-up internal resistor
bsf STATUS,RP0 ; Bank 1
bcf STATUS,RP1 ; " "
bcf OPTION_REG,NOT_RABPU ; Activate pull-up resistors - Clear RABPU flag
bcf STATUS,RP0 ; Bank 0
bcf STATUS,RP1 ; " "
movlw PORTB ; move portb to W
movwf portbtmp ; to tmp
bsf STATUS,RP0 ; Bank 1
bcf STATUS,RP1 ; " "
bsf OPTION_REG,NOT_RABPU; Deactivate pull-up resistors - Set RABPU flag
bcf STATUS,RP0 ; Back to Bank 0
bcf STATUS,RP1 ; " " "
btfsc portbtmp,7 ; Key Up pressed?
goto $+3 ; No
bcf PORTB,6 ; Yes, set led
goto $+2 ; Exit
bsf PORTB,6 ; No, reset led
bcf PORTC,2 ; enable led
CLRF dcount
delay1:
DECFSZ dcount,F ; give led some time to show
GOTO delay1
goto START
END
H_keeping:
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
bcf STATUS,RP0 ; Bank 2
bsf STATUS,RP1 ; " "
movlw B'11110000' ;
movwf WPUB ; Enable RB4, RB5, RB6 and RB7 pull-up internal resistors
bsf STATUS,RP0 ; Bank 1
bcf STATUS,RP1 ;
bsf OPTION_REG,7 ; Set RABPU flag
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'
movwf WPUA
bcf STATUS,RP0 ; Bank 2
bsf STATUS,RP1 ;
movlw B'00000000'
movwf WPUB
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
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
I though that it was necessary to make the leds/display work fine (never tested if not necessary.why do you want to set and clear the weak pullups??
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?