Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<p18F4550.inc>
- CONFIG FOSC = HS ; H oscillator, HS used by USB
- CONFIG WDT = OFF ; HW disabled - SW Controlled ( deactivation des watchdog timer)
- CONFIG DEBUG = OFF
- CONFIG MCLRE = OFF ;
- CONFIG CPUDIV = OSC1_PLL2
- CONFIG PBADEN = OFF
- counter_value equ H'04'
- RES_VECTOR CODE 0x0000;
- goto init
- org 0x0008 ; interrupt vector at PM address 0x0008
- goto irq_handle ; go to the function for the
- INT0_interrupt
- ; --- clear the TMR0 interrupt flag
- ; note : it is COMPULSORY to clear the flag
- bcf INTCON , INT0IF ; clear the flag
- ; --- increment PORTC
- incf PORTC
- retfie
- irq_handle ; --- interrupt routine
- ; --- flag test -> is it the INT0 ?
- btfsc INTCON , INT0IF
- goto INT0_interrupt ; yes , it is TMR0
- retfie ; --- no , return from interrupt
- MAIN_PROG CODE
- init
- clrf TRISD ; set PORTD as output
- clrf PORTD ; clear PORTD
- clrf TRISC ; set PORTC as output
- clrf PORTC ; clear PORTC
- setf TRISB ;
- clrf PORTB ; clear PORTB
- ; set timer mode
- bsf INTCON , GIE ; activate interrupts
- bsf INTCON , INT0IE ; activate external interrupt
- ; set interrupt on BO
- bcf INTCON, INTEDG0
- goto main_loop
- main_loop
- call seg_set_0
- goto main_loop ; push skipped
- seg_set_0
- movlw H'00'
- CPFSEQ counter_value
- goto seg_set_1
- movlw H'3F'
- movwf PORTD
- return
- seg_set_1
- movlw H'01'
- CPFSEQ counter_value
- goto seg_set_2
- movlw H'06'
- movwf PORTD
- return
- seg_set_2
- movlw H'02'
- CPFSEQ counter_value
- goto seg_set_3
- movlw H'5B'
- movwf PORTD
- return
- seg_set_3
- movlw H'03'
- CPFSEQ counter_value
- goto seg_set_4
- movlw H'4F'
- movwf PORTD
- return
- seg_set_4
- movlw H'04'
- CPFSEQ counter_value
- goto seg_set_5
- movlw H'66'
- movwf PORTD
- return
- seg_set_5
- movlw H'05'
- CPFSEQ counter_value
- goto seg_set_6
- movlw H'6D'
- movwf PORTD
- return
- seg_set_6
- movlw H'06'
- CPFSEQ counter_value
- goto seg_set_7
- movlw H'7D'
- movwf PORTD
- return
- seg_set_7
- movlw H'07'
- CPFSEQ counter_value
- goto seg_set_8
- movlw H'07'
- movwf PORTD
- return
- seg_set_8
- movlw H'08'
- CPFSEQ counter_value
- goto seg_set_9
- movlw H'7F'
- movwf PORTD
- return
- seg_set_9
- movlw H'09'
- CPFSEQ counter_value
- return
- movlw H'6F'
- movwf PORTD
- return
- counter_reset
- clrf counter_value
- return
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement