Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- list p=PIC18f8722
- #include p18f8722.inc
- CONFIG OSC = HS, WDT = OFF, LVP = OFF
- #define LED LATD
- #define LED_IO TRISD
- #define BUTTON PORTA,RA5
- #define BUTTON_IO TRISA,RA5
- ; Begin
- code 0
- goto initialize
- ; Memory mapping
- udata
- counter res .3
- cycle res .1
- ; Start
- PRG code
- initialize
- clrf LED_IO
- clrf LED
- movlw H'0F'
- movwf ADCON1
- bsf BUTTON_IO
- movlw .5
- movwf cycle
- main btfsc BUTTON ; if button not pushed
- bra led_change ; then change LED
- decfsz cycle ; else change cycle
- bra button_pushed
- movlw .5
- movwf cycle
- button_pushed
- btfss BUTTON
- bra button_pushed
- led_change
- incf LED
- call delay_500ms
- bra main
- delay_400us
- movlw .249
- movwf counter
- nop
- delay_400us_loop
- nop
- decfsz counter
- bra delay_400us_loop
- return
- delay_500ms
- movf cycle, W
- movwf counter + 1
- delay_500ms_loop1
- movlw .250
- movwf counter + 2
- delay_500ms_loop2
- call delay_400us
- decfsz counter + 2
- bra delay_500ms_loop2
- decfsz counter + 1
- bra delay_500ms_loop1
- return
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement