1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  1. Fire Starter

    Fire Starter New Member

    Joined:
    Jan 7, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    G'day. Just wondering if anyone could let me know if they can see any bugs in this program... been over it heaps but I still cant see why its not doing what its suppose to be doing. What it is suppose to be doing is tuning on a led out of port Rb4 when an input is recived from port Ra0.
    thanks.
    The Fire Starter.

    Code:
    Code:
    	   maclib  'p16f8x.inc'
    ;
                       device  pic16f84,xt_osc,wdt_off,pwrt_on,protect_off
    ;
    leds          =       portb           ;led output port
    Input	=       porta
    ;
    dir_b         =       00h             ;all out
    dir_a	=       01h		;RA0 in
    ;
    	org     0ch             ;start of ram space
    ;
    	org     0               ;reset vector
    ;
    	jmp     start           ;go to beginning of program on reset
    ;
    	org     5               ;start of code space
    ;
    ;
    ;	sets up leds and direction registers
    ;
    start         mov     leds,#0         ;start with all leds off
                    setb    rp0             ;point to register page 1
                    mov     trisb,#dir_b    ;set port b data direction register
    	mov	trisa,#dir_a	;set port a data direction register
                    clrb    rp0             ;point back to register page 0
    ;
    ;
    ; main loop to light leds when input on pin Ra0
    ;
    ;
    ledon
    	mov   leds,8		;turn leds on at port Rb4
    	jmp   mainloop	;do it forever
    ;
    ;
    mainloop 
    	cje     1,input,ledon	;compare the input to the value 1 and jump if equal
    	mov    leds,0		;turn leds off if input is not present
    	jmp     mainloop        ;do it forever
     
    Last edited by a moderator: Jan 8, 2007
  2. Fire Starter

    Fire Starter New Member

    Joined:
    Jan 7, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    P.S Sorry About the spaceing of the code....
     

Share This Page