list p=18F1320
include <p18F1320.inc>
CONFIG OSC = INTIO2, WDT = OFF, LVP = OFF
LED macro x,y ;MACRO LED <PORTA>, <TRISA>
movlw x
movwf LATA ;LATA = x
movlw y
movwf TRISA ;TRISA = y
call Delay ;call the Delay subroutine
endm ;end macro
Count equ 0 ;delay loop counter
org 0x00 ; reset vector
goto Main
org 0x08 ; ISR Low vector
goto ISR
org 0x18 ; ISR Low vector
goto ISR
Main
; bsf ADCON1,0 ;make RA0 digital
CLRF PORTB ;Initialize PORTB by clearing output data latches
CLRF LATB ;Alternate method to clear output data latches
MOVLW b'00000001'
MOVWF ADCON1
MOVLW b'11010101'
MOVWF ADCON0
MOVLW b'00010011'
MOVWF ADCON2
MOVLW b'11001111'
MOVWF TRISB
MOVLW b'11111000'
MOVWF INTCON
MOVLW b'01110000'
MOVWF INTCON2
MOVLW b'00011000'
MOVWF INTCON3
MOVLW b'01000000'
MOVWF PIE1
LED1 LED b'00000001',b'10111110'
LED2 LED b'01000000',b'10111110'
LED3 LED b'01000000',b'00111111'
LED4 LED b'10000000',b'00111111'
LED5 LED b'10000000',b'01111110'
LED6 LED b'00000001',b'01111110'
goto LED1 ;loop forever
Delay decfsz Count,f ;decrement Count and skip when zero
goto $-2 ;not zero? repeat
return
ISR BCF INTCON3, 0
BCF INTCON3, 1
BCF INTCON, 0
BCF INTCON, 1
BCF INTCON, 2
call Delay
LED b'00000001',b'01111110'
call Delay
BSF ADCON0, 1
Loop1 BTFSC ADCON0, 1
goto Loop1
call Delay
call Delay
retfie
END
list p=18F1320
include <p18F1320.inc>
CONFIG OSC = INTIO2, WDT = OFF, LVP = OFF
cblock 0x00
advtemp
endc
LED macro x,y ;MACRO LED <PORTA>, <TRISA>
movlw x
movwf LATA ;LATA = x
movlw y
movwf TRISA ;TRISA = y
call Delay ;call the Delay subroutine
endm ;end macro
Count equ 0 ;delay loop counter
org 0x00 ; reset vector
goto Main
org 0x08 ; ISR Low vector
goto ISR
org 0x18 ; ISR Low vector
goto ISR
Main
; bsf ADCON1,0 ;make RA0 digital
CLRF PORTB ;Initialize PORTB by clearing output data latches
CLRF LATB ;Alternate method to clear output data latches
MOVLW 0x10 ;b'00010001' ; Set RB0
MOVWF ADCON1 ;digital I/O pin
MOVLW b'11001111' ;0xCF ;Value used to initialize data direction
MOVWF TRISB ;Set RB<3:0> as inputs RB<5:4> as outputs RB<7:6> as inputs
MOVLW b'11111000' ;b'11011000'
MOVWF INTCON
MOVLW b'01110000' ;b'11110101'
MOVWF INTCON2
MOVLW b'00011000' ;b'00001000'
MOVWF INTCON3
movlw b'00010101' ;enable A/D, AN5
movwf ADCON0
LED1 LED b'00000001',b'10111110'
LED2 LED b'01000000',b'10111110'
LED3 LED b'01000000',b'00111111'
LED4 LED b'10000000',b'00111111'
bsf ADCON0,GO ;go do a/d conversion
adloop btfsc ADCON0,DONE
goto adloop
;movff ADRESH,advtemp
MOVLW 0x80
NoChange CPFSGT ADRESH
goto Check1
goto LED1 ;loop forever
Check1 MOVLW 0x80
CPFSEQ ADRESH
goto Check2
goto LED6
Check2 MOVLW 0x00
CPFSEQ ADRESH
goto LED1
goto LED5
LED5 LED b'10000000',b'01111110'
call Delay
call Delay
goto LED1
LED6 LED b'00000001',b'01111110'
call Delay
call Delay
goto LED1 ;loop forever
Delay decfsz Count,f ;decrement Count and skip when zero
goto $-2 ;not zero? repeat
return
ISR BCF INTCON3, 0
BCF INTCON3, 1
BCF INTCON, 0
BCF INTCON, 1
BCF INTCON, 2
call Delay
LED b'00000001',b'01111110'
call Delay
call Delay
call Delay
retfie
END
list p=18F1320
include <p18F1320.inc>
CONFIG OSC = INTIO2, WDT = OFF, LVP = OFF
cblock 0x00
advtemp
L2T
endc
LED macro x,y ;MACRO LED <PORTA>, <TRISA>
movlw x
movwf LATA ;LATA = x
movlw y
movwf TRISA ;TRISA = y
call Delay ;call the Delay subroutine
endm ;end macro
Count equ 0 ;delay loop counter
org 0x00 ; reset vector
goto Main
org 0x08 ; ISR Low vector
goto ISR
org 0x18 ; ISR Low vector
goto ISR
Main
; bsf ADCON1,0 ;make RA0 digital
CLRF PORTB ;Initialize PORTB by clearing output data latches
CLRF LATB ;Alternate method to clear output data latches
MOVLW 0x10 ;b'00010001' ; Set RB0
MOVWF ADCON1 ;digital I/O pin
MOVLW b'11001111' ;0xCF ;Value used to initialize data direction
MOVWF TRISB ;Set RB<3:0> as inputs RB<5:4> as outputs RB<7:6> as inputs
MOVLW b'11111000' ;b'11011000'
MOVWF INTCON
MOVLW b'01110000' ;b'11110101'
MOVWF INTCON2
MOVLW b'00011000' ;b'00001000'
MOVWF INTCON3
movlw b'00010101' ;enable A/D, AN5
movwf ADCON0
StartUp bsf ADCON0,GO ;go do a/d conversion
adloop btfsc ADCON0,DONE
goto adloop
;movff ADRESH,advtemp
; MOVLW 0x80
;NoChange CPFSGT ADRESH
;goto Check1
;goto adloop ;loop forever
MOVLW 0x02
MOVWF L2T
Check1 MOVLW 0x80
CPFSEQ ADRESH
goto Check2
goto LED2T
Check2 MOVLW 0x00
CPFSEQ ADRESH
goto StartUp
goto LED1T
LED1T
LED b'00000001',b'10111110'
LED b'01000000',b'10111110'
LED b'01000000',b'00111111'
LED b'10000000',b'00111111'
LED b'10000000',b'01111110'
LED b'00000001',b'01111110'
goto StartUp
LED2T
LED b'00000001',b'10111110'
LED b'01000000',b'10111110'
LED b'01000000',b'00111111'
LED b'10000000',b'00111111'
LED b'10000000',b'01111110'
LED b'00000001',b'01111110'
DECFSZ L2T
goto LED2T
goto StartUp ;loop forever
Delay decfsz Count,f ;decrement Count and skip when zero
goto $-2 ;not zero? repeat
return
ISR BCF INTCON3, 0
BCF INTCON3, 1
BCF INTCON, 0
BCF INTCON, 1
BCF INTCON, 2
call Delay
LED b'00000001',b'01111110'
call Delay
retfie
END
list p=18F1320
include <p18F1320.inc>
CONFIG OSC = INTIO2, WDT = OFF, LVP = OFF
cblock 0x00
advtemp
L2T
endc
LED macro x,y ;MACRO LED <PORTA>, <TRISA>
movlw x
movwf LATA ;LATA = x
movlw y
movwf TRISA ;TRISA = y
call Delay ;call the Delay subroutine
endm ;end macro
Count equ 0 ;delay loop counter
org 0x00 ; reset vector
goto Main
org 0x08 ; ISR Low vector
goto ISR
org 0x18 ; ISR Low vector
goto ISR
Main
; bsf ADCON1,0 ;make RA0 digital
CLRF PORTB ;Initialize PORTB by clearing output data latches
CLRF LATB ;Alternate method to clear output data latches
MOVLW 0x10 ;b'00010001' ; Set RB0
MOVWF ADCON1 ;digital I/O pin
MOVLW b'11001111' ;0xCF ;Value used to initialize data direction
MOVWF TRISB ;Set RB<3:0> as inputs RB<5:4> as outputs RB<7:6> as inputs
MOVLW b'11001000' ;b'01111000' ;b'11011000'
MOVWF INTCON
MOVLW b'11110101' ;b'01110000' ;b'11110101'
MOVWF INTCON2
MOVLW b'11011000' ;b'00011000' ;b'00001000'
MOVWF INTCON3
movlw b'00010101' ;enable A/D, AN5
movwf ADCON0
StartUp bsf ADCON0,GO ;go do a/d conversion
adloop btfsc ADCON0,DONE
goto adloop
;movff ADRESH,advtemp
; MOVLW 0x80
;NoChange CPFSGT ADRESH
;goto Check1
;goto adloop ;loop forever
MOVLW 0x02
MOVWF L2T
Check1 MOVLW 0x80
CPFSEQ ADRESH
goto Check2
goto LED2T
Check2 MOVLW 0x00
CPFSEQ ADRESH
goto StartUp
goto LED1T
LED1T
LED b'00000001',b'10111110'
LED b'01000000',b'10111110'
LED b'01000000',b'00111111'
LED b'10000000',b'00111111'
LED b'10000000',b'01111110'
LED b'00000001',b'01111110'
goto StartUp
LED2T
LED b'00000001',b'10111110'
LED b'01000000',b'10111110'
LED b'01000000',b'00111111'
LED b'10000000',b'00111111'
LED b'10000000',b'01111110'
LED b'00000001',b'01111110'
DECFSZ L2T
goto LED2T
goto StartUp ;loop forever
Delay decfsz Count,f ;decrement Count and skip when zero
goto $-2 ;not zero? repeat
return
ISR BCF INTCON3, 0
BCF INTCON3, 1
BCF INTCON, 0
BCF INTCON, 1
BCF INTCON, 2
call Delay
LED b'00000001',b'01111110'
call Delay
retfie
END
list p=18F1320
include <p18F1320.inc>
CONFIG OSC = INTIO2, WDT = OFF, LVP = OFF
cblock 0x00
advtemp
L2T
endc
LED macro x,y ;MACRO LED <PORTA>, <TRISA>
movlw x
movwf LATA ;LATA = x
movlw y
movwf TRISA ;TRISA = y
call Delay ;call the Delay subroutine
endm ;end macro
Count equ 0 ;delay loop counter
org 0x00 ; reset vector
goto Main
org 0x08 ; ISR Low vector
goto ISR
org 0x18 ; ISR Low vector
goto ISR
Main
; bsf ADCON1,0 ;make RA0 digital
CLRF PORTB ;Initialize PORTB by clearing output data latches
CLRF LATB ;Alternate method to clear output data latches
MOVLW 0x10 ;b'00010001' ; Set RB0
MOVWF ADCON1 ;digital I/O pin
MOVLW b'11001111' ;0xCF ;Value used to initialize data direction
MOVWF TRISB ;Set RB<3:0> as inputs RB<5:4> as outputs RB<7:6> as inputs
MOVLW b'11001000' ;b'01111000' ;b'11011000'
MOVWF INTCON
MOVLW b'11110101' ;b'01110000' ;b'11110101'
MOVWF INTCON2
MOVLW b'11011000' ;b'00011000' ;b'00001000'
MOVWF INTCON3
movlw b'00010101' ;enable A/D, AN5
movwf ADCON0
StartUp bsf ADCON0,GO ;go do a/d conversion
adloop btfsc ADCON0,DONE
goto adloop
;movff ADRESH,advtemp
; MOVLW 0x80
;NoChange CPFSGT ADRESH
;goto Check1
;goto adloop ;loop forever
MOVLW 0x02
MOVWF L2T
Check1 MOVLW 0x80
CPFSEQ ADRESH
goto Check2
goto LED2T
Check2 MOVLW 0x00
CPFSEQ ADRESH
goto StartUp
goto LED1T
LED1T
call ScrollMe
goto StartUp
LED2T
call ScrollMe
DECFSZ L2T
goto LED2T
goto StartUp ;loop forever
Delay decfsz Count,f ;decrement Count and skip when zero
goto $-2 ;not zero? repeat
return
ScrollMe
LED b'00000001',b'10111110'
LED b'01000000',b'10111110'
LED b'01000000',b'00111111'
LED b'10000000',b'00111111'
LED b'10000000',b'01111110'
LED b'00000001',b'01111110'
return
ISR BCF INTCON3, 0
BCF INTCON3, 1
BCF INTCON, 0
BCF INTCON, 1
BCF INTCON, 2
call Delay
LED b'00000001',b'01111110'
call Delay
retfie
END
list p=18F1320
include <p18F1320.inc>
CONFIG OSC = INTIO2, WDT = OFF, LVP = OFF
cblock 0x00
advtemp
L2T
endc
LED macro x,y ;MACRO LED <PORTA>, <TRISA>
movlw x
movwf LATA ;LATA = x
movlw y
movwf TRISA ;TRISA = y
call Delay ;call the Delay subroutine
endm ;end macro
Count equ 0 ;delay loop counter
org 0x00 ; reset vector
goto Main
org 0x08 ; ISR Low vector
goto ISR
org 0x18 ; ISR Low vector
goto ISR
Main
; bsf ADCON1,0 ;make RA0 digital
CLRF PORTB ;Initialize PORTB by clearing output data latches
CLRF LATB ;Alternate method to clear output data latches
MOVLW 0x10 ;b'00010001' ; Set RB0
MOVWF ADCON1 ;digital I/O pin
MOVLW b'11001111' ;0xCF ;Value used to initialize data direction
MOVWF TRISB ;Set RB<3:0> as inputs RB<5:4> as outputs RB<7:6> as inputs
MOVLW b'11001000' ;b'01111000' ;b'11011000'
MOVWF INTCON
MOVLW b'11110101' ;b'01110000' ;b'11110101'
MOVWF INTCON2
MOVLW b'11011000' ;b'00011000' ;b'00001000'
MOVWF INTCON3
movlw b'00010101' ;enable A/D, AN5
movwf ADCON0
StartUp bsf ADCON0,GO ;go do a/d conversion
adloop btfsc ADCON0,DONE
goto adloop
;movff ADRESH,advtemp
; MOVLW 0x80
;NoChange CPFSGT ADRESH
;goto Check1
;goto adloop ;loop forever
MOVLW 0xEE
CPFSLT ADRESH
goto StartUp
MOVLW 0x02
MOVWF L2T
Check1 MOVLW 0xBF
CPFSGT ADRESH
goto Check2
MOVLW 0x04
MOVWF L2T
goto LEDXT
Check2 MOVLW 0x7F
CPFSGT ADRESH
goto Check3
MOVLW 0x03
MOVWF L2T
goto LEDXT
Check3 MOVLW 0x3F
CPFSGT ADRESH
goto Check4
MOVLW 0x02
MOVWF L2T
goto LEDXT
Check4 MOVLW 0x00
CPFSEQ ADRESH
goto StartUp
goto LED1T
LED1T
call ScrollMe
goto StartUp
LEDXT
call ScrollMe
DECFSZ L2T
goto LEDXT
goto StartUp ;loop forever
Delay decfsz Count,f ;decrement Count and skip when zero
goto $-2 ;not zero? repeat
return
ScrollMe
LED b'00000001',b'10111110'
LED b'01000000',b'10111110'
LED b'01000000',b'00111111'
LED b'10000000',b'00111111'
LED b'10000000',b'01111110'
LED b'00000001',b'01111110'
return
ISR BCF INTCON3, 0
BCF INTCON3, 1
BCF INTCON, 0
BCF INTCON, 1
BCF INTCON, 2
call Delay
LED b'00000001',b'01111110'
call Delay
retfie
END
list p=18F1320
include <p18F1320.inc>
CONFIG OSC = INTIO2, WDT = OFF, LVP = OFF
cblock 0x00
advtemp
L2T
endc
LED macro x,y ;MACRO LED <PORTA>, <TRISA>
movlw x
movwf LATA ;LATA = x
movlw y
movwf TRISA ;TRISA = y
call Delay ;call the Delay subroutine
endm ;end macro
Count equ 0 ;delay loop counter
org 0x00 ; reset vector
goto Main
org 0x08 ; ISR Low vector
goto ISR
org 0x18 ; ISR Low vector
goto ISR
Main
CLRF PORTB ;Initialize PORTB by clearing output data latches
CLRF LATB ;Alternate method to clear output data latches
MOVLW 0x01 ;A/D Config
MOVWF ADCON1 ;ADCON1: All analog except AN0
MOVLW b'00000010' ;TRISB Config
MOVWF TRISB ;Set RB1 as input RB<7:2> and RB0 as outputs
MOVLW b'11001000' ;INTCON Config
MOVWF INTCON ;Enable GIE/GIEH, PEIE/GIEL, RBIE Disable rest
MOVLW b'11110101' ;INTCON2 Config
MOVWF INTCON2 ;Enable RBPU, Rising Edge Interrupts, High Priority
MOVLW b'11001000' ;INTCON3 Config
MOVWF INTCON3 ;High Priority, Enable INT1 and Clear Flags
movlw b'00010101' ;enable A/D, AN5
movwf ADCON0
StartUp bsf ADCON0,GO ;Start A/D conversion
adloop btfsc ADCON0,DONE ;Check if done. If not goto adloop else skip loop
goto adloop
MOVLW 0xEE ;Button Pressed Preset
CPFSLT ADRESH ;If ADRESH < Skip the goto else start over
goto StartUp ;because no button pressed
Check1 MOVLW 0xBF ;4th button Preset
CPFSGT ADRESH ;If ADRESH > BFH then this button was pressed
goto Check2 ;If not then it wasnt pressed skip to next check
MOVLW 0x04
MOVWF L2T ;Set L2T to 0x04 (MY LOOP COUNTER)
goto LEDXT ;Goto LEDXT which is the Light X Times where x = 4h for this button
Check2 MOVLW 0x7F ;3rd button preset
CPFSGT ADRESH ;If ADRESH > 7FH then this button was pressed
goto Check3 ;If not then it wasnt pressed skip to next check
MOVLW 0x03
MOVWF L2T ;Set L2T to 0x03 (MY LOOP COUNTER)
goto LEDXT ;Goto LEDXT which is the Light X Times where x = 3h for th
Check3 MOVLW 0x3F ;Same as others
CPFSGT ADRESH
goto Check4
MOVLW 0x02
MOVWF L2T
goto LEDXT
Check4 MOVLW 0x00 ;Same
CPFSEQ ADRESH ;If ADRESH = 0 then goto LED1T because button 1 was hit
goto StartUp ;if not then goto startup
goto LED1T ;LED 1 Time
LED1T
call ScrollMe ;Scroll LEDs 1 time
goto StartUp ;Goto Startup
LEDXT ;LEDXT loop
call ScrollMe ;Scroll 1 time
DECFSZ L2T ;Decrement L2T and skip the next line if 0
goto LEDXT ;goto ledxt loop
goto StartUp ;Goto StartUp
Delay decfsz Count,f ;decrement Count and skip when zero
goto $-2 ;not zero? repeat
return
ScrollMe
LED b'00000001',b'10111110' ; Light LED 1
LED b'01000000',b'10111110' ; Light LED 2
LED b'01000000',b'00111111' ; Light LED 3
LED b'10000000',b'00111111' ; Light LED 4
LED b'10000000',b'01111110' ; Light LED 5
LED b'00000001',b'01111110' ; Light LED 6
return ; Return from where called
ISR BCF INTCON3, 0 ; Clear INT1
BCF INTCON, 0 ; Clear RBIF: RB Port Change Interrupt Flag bit
LED b'00000001',b'01111110' ; Light LED 6
call Delay ; 2 delays
call Delay
retfie ; Return from where called
END
AtomSoft said:yep thank god but it takes like 30 seconds to reset is that normal?
movlw 0x72 ; 8MHz clock select
movwf OSCCON
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?