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
- direction res .1
- direction_bit equ 0
- #define DIRECTION direction,direction_bit
- ; Start
- PRG code
- initialize
- clrf LED_IO
- movlw H'C0'
- movwf LED
- movlw H'0F'
- movwf ADCON1
- bsf BUTTON_IO
- clrf direction
- main btfsc BUTTON ; if button not pushed
- bra led_change ; then change LED
- btg DIRECTION ; else change direction
- button_pushed
- btfss BUTTON
- bra button_pushed
- led_change
- btfsc DIRECTION
- bra led_change1
- rlncf LED
- bra led_change2
- led_change1
- rrncf LED
- led_change2
- 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
- movlw .5
- 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