Rob This was added to make sure all 12 leds would come on and they did. I didnt understand it either because the code examples I showed nothing like this but it did work witht the exception of the fore mentioned problem. thanks Michael Johnston ----- Original Message ----- From: "Rob Stockley" To: Sent: Monday, January 12, 2004 11:00 PM Subject: Re: [PIC:] 16c54 scanner > On Tue, 2004-01-13 at 12:43, Michael Johnston wrote: > > Tony > > Here is my code you asked for. My delay was adapted from some code on > > the pic list archive. > > thanks > > You've a lot of unnecessary stuff and the delays are misplaced. I'm > relatively new to PICs but these are my observations and example code, > > * don't need counter since last bit already serves as a limit so no need > to check Z either. > * before you set the next bit check it is not the last bit > * set the next bit then delay not the other way around > * don't need to clear C since your rotates should never carry and you > never checked it anyway > > ;put your setup stuff here > > start_condition > clrf PORTB ;clear all portb > movf 0x01 > movwf PORTA ;set only pin0 on porta > pointaf > btfsc PORTA,3 ;if bit 3 is lit > goto change_ab ;then we're ready to change ports > rlf PORTA,same ;otherwise rotate > call delay > goto pointaf > change_ab > clrf PORTA ;finished with porta for now > bsf PORTB,0 ;set bit 0 on portb > ;others are already off > pointbf > btfsc PORTB,7 ;if bit 7 is lit > goto pointbr ;then we're ready to reverse > rlf PORTB,same ;otherwise rotate > call delay > goto pointbf > pointbr > btfsc PORTB,0 ;if bit 0 is lit > goto change_ba ;then we're ready to change ports > rrf PORTB,same ;otherwise rotate > call delay > goto pointbr > change_ba > clrf PORTB ;finished with portb for now > bsf PORTA,3 ;set bit 3 on porta > ;others are already off > pointar > btfsc PORTA,0 ;if bit 0 is lit > goto pointaf ;then we're ready to start again > rrf PORTA,same ;otherwise rotate > call delay > goto pointar > > goto start_condition ;should never get to here > ;but just in case > > -- > 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 list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics