Rob Thanks for the information.I am using a picstart plus from microchip to program my chip. My friend, a local engineer came up with this idea and i implemented his idea and ran into this problem. He keeps telling its my part this is causing this problem. But I modify the program to run in an F 84 and it did the same thing. . The idea about the pass counter was to make sure that all the leds would come on and they do. This was old idea that i had some years back thanks again Mike Johnston ----- Original Message ----- From: "Rob Stockley" To: Sent: Tuesday, January 13, 2004 10:27 PM Subject: Re: [PIC:] 16c54 scanner > Michael, > > Let me try to explain what is going wrong by rewriting the comments in > your code. I have not changed or removed any commands, just the > comments. > > pascnt1 > movlw 0x05 > movwf C1 ;counter contains value 5 > > setbitaf > clrf PORTB ;portb leds all off > bsf PORTA,0 ;first led of porta is lit > pointaf > decf C1,f ;decrease counter by one > call delay ;wait a bit > bcf STATUS,C > rlf PORTA,same ;change to the next led in porta > btfsc PORTA,3 ;if the fourth led is lit > goto pascnt2 ;time to switch ports > ;but hang on we only just lit the > ;fourth led. Don't we need to wait > ;a bit? > movf C1,f ;when PORTA,3 is lit, C1=2 so Z will > ;never be set by this command > btfss STATUS,Z ;Z is never set so we always execute > ;the next instruction > goto pointaf ;keep processing porta > pascnt2 > movlw 0x09 ;switching to portb so > movwf C1 ;load counter with 9 > setbitbf > clrf PORTA ;turn all porta off > ;remember this is only 5 instructions > ;since we turned it on!! > bsf PORTB,0 ;turn on portb's first led > ..........etc > > Do you see how your delays are misplaced? A simple fix would be to > insert another "call delay" immediately after pascnt2. You'll need to > modify your reverse routines in a similar way. > > Also, to tidy up your code, ask yourself these questions; > > What does the counter do? > What does checking PORTA,3 do? > > If the answers to these are the same then you most likely only need one > of them. > > When will the Z flag be set? > Can this ever happen? > > I hope all this is helpful. PICs are great fun to work with. Out of > interest, what are you using to program them? > > Rob > > -- > http://www.piclist.com hint: The list server can filter out subtopics > (like ads or off topics) for you. See http://www.piclist.com/#topics -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.