my code stock.com

Snippet options

Download: Download snippet as asm-bit-toggle.txt.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

config PLLDIV = 1
    config CPUDIV = OSC1_PLL2
    config USBDIV = 2
    config FOSC = HS
     
    ADCON1 EQU 0xFC1
    PORTA  EQU 0xF80
    PORTB  EQU 0xF81
    TRISA  EQU 0xF92
    TRISB  EQU 0XF93
     
    MOVLW 0x0F
    MOVWF ADCON1,0
     
    MOVLW 0xFF
    MOVWF TRISA,0
    MOVLW 0x00
    MOVWF TRISB, 0
     
    ANT EQU 0x01
     
    poll
            BTFSC PORTA,0,0
            BRA poll1
            BRA poll2
    poll1
            MOVLW 0x00		; W -> 0x00
            CPFSGT ANT, 0  ; Comparem ANT amb W
            BRA button
            BRA poll
    poll2
            MOVLW 0x00	
            MOVWF ANT, 0   ; ANT = 0
            BCF PORTA,0
            BRA poll
     
    button
            MOVLW 0x01
            MOVWF ANT, 0   ; 0x001 = 1, boto apretat 
            BTFSC PORTB,0,0 ;Comprobem el estat del led 
            BRA ledon
            BRA ledoff
 
    ledon
            BCF PORTB,0,0  ; Led ences -> Led apagat 
            BCF PORTA,0
            BRA poll
           
    ledoff
            BSF PORTB,0,0   ; Led apagat -> Led ences 
            BCF PORTA,0
            BRA poll
     
    END

Create a free my code stock.com account now.

my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.