Hey Tony I assembled the code and it works great and now its in the c54. Thanks Again for your help Michael Johnston ----- Original Message ----- From: "Tony Nixon" To: Sent: Monday, January 12, 2004 6:28 PM Subject: Re: [PIC:] 16c54 scanner > Hi Michael, > > See new attached code. > > Assemble it in MPLAB and add the variabled PB_A and PB_B to the watch > window in binary format. > > Comment out the delay_write subroutine calls like this... > > call delay_write > > to... > > ; call delay_write > > Now assemble and step through the code to see how it works. > > When happy, un comment the delay_write subroutine calls and program a > chip to test. > > regards > > Tony > > Michael Johnston wrote: > > >Tony > > Here is my code you asked for. My delay was adapted from some code on > >the pic list archive. > >thanks > >Mike Johnston > >----- Original Message ----- > >From: "Tony Nixon" > >To: > >Sent: Sunday, January 11, 2004 10:07 PM > >Subject: Re: [PIC:] 16c54 scanner > > > > > > > > > -- > http://www.piclist.com hint: PICList Posts must start with ONE topic: > [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads > > > ---------------------------------------------------------------------------- ---- > ;*************************************************************************** ****************** > LIST p=16c54c > include "p16c5x.inc" > radix hex > ;*************************************************************************** ****************** > cblock 0x08 > D1 > D2 > C1 > PB_A > PB_B > endc > ; > same equ 0x01 > ;*************************************************************************** ******************* > org 0x000 > ;*************************************************************************** ******************* > start > movlw 0x00 > movwf PORTA ;porta all bits low > tris PORTA ;porta all pins output > movlw 0x00 > movwf PORTB ;portb all bits low > tris PORTB ;aportb all pins output > > movlw b'00000001' > movwf PB_A ; used for PORTA LED on, RA0 = 0N to start > clrf PB_B ; used for PORTB LED on, all OFF to start > > ;*************************************************************************** ****************** > ; Port A,b Forward > ;*************************************************************************** ***************** > A_Left > call delay_write ; write to port and delay to see it > > bcf STATUS,C ; shift LED bit left once > rlf PB_A,same > btfss PB_A,4 ; if PB_A bit 4 = 1, scan moves into PB_B > goto A_Left ; not 1 > > clrf PB_A ; clear bits in PB_A > movlw b'00000001' ; set LED ON in PORTB 0 > movwf PB_B > > B_Left > call delay_write ; write to port and delay to see it > bcf STATUS,C ; shift LED bit left once > rlf PB_B,same > btfss STATUS,C ; PB_B = 0 and carry = 1 if all done > goto B_Left > > movlw b'01000000' ; start portB moving right > movwf PB_B > > B_Right > call delay_write ; write to port and delay to see it > bcf STATUS,C ; shift LED bit right once > rrf PB_B,same > btfss STATUS,C ; PB_B = 0 and carry = 1 if all done > goto B_Right > > movlw b'00001000' ; set LED ON in PORTA 3 > movwf PB_A ; PB_B = 0 > > A_Right > call delay_write ; write to port and delay to see it > bcf STATUS,C ; shift LED bit right once > rrf PB_A,same > btfss STATUS,C ; PB_A = 0 and carry = 1 is all done > goto A_Right > > movlw b'00000001' ; start port A moving left again > movwf PB_A > goto A_Left > > ;*************************************************************************** ******************* > delay_write > movf PB_A,W ; set port A and B LED > movwf PORTA > movf PB_B,W > movwf PORTB > > movlw 0x7f ; delay > movwf D1 > clrf D2 > delay_0 > decfsz D1,f > goto $-1 > decfsz D2,f > goto delay_0 > retlw 0x00 > > > > ;*************************************************************************** ******************* > end > > > > > > -- > http://www.piclist.com hint: PICList Posts must start with ONE topic: > [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads > > > -- 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