This is a multi-part message in MIME format. ------=_NextPart_000_0014_01C3D933.89139FB0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit 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 > Michael Johnston wrote: > > >Hi guys > > I wrote a program that i adaptive with help from a friend to flash 12 leds tied to the 12 I/O Pins on c54. I have four routines that rotate the bit pattern through porta and portb forwards and backwards. My problem is that when the routine is going from porta to portb forward ra3 flashes so fast and jumps to portb bit0 so fast you can not see this happening. It also does this when going backwards from portb to porta. But it portb bit 7 that you dont see flashing. My friend told me the reason this was happening was because of the part i am using so i ported it to F84 and the program did the same thing in this port. I need so type of a delay but everything i try seems to mess my code up. > >Thanks > >Mike Johnston > > > >-- > >http://www.piclist.com hint: To leave the PICList > >mailto:piclist-unsubscribe-request@mitvma.mit.edu > > > > > Can you post the code so we can PIC through it :-) > > regards > > Tony > > -- > http://www.piclist.com hint: To leave the PICList > mailto:piclist-unsubscribe-request@mitvma.mit.edu -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads ------=_NextPart_000_0014_01C3D933.89139FB0 Content-Type: application/octet-stream; name="54.asm" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="54.asm" ;************************************************************************= ********************* LIST p=3D16c54c include "p16c5x.inc" radix hex ;************************************************************************= ********************* cblock 0x08 D1 D2 C1 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 ;************************************************************************= ********************* ; Port A,b Forward ;************************************************************************= ******************** pascnt1 movlw 0x05 ;load pass counter (C1) with 5 movwf C1 ;becasuse we have 4 bits in porta to scan setbitaf clrf PORTB bsf PORTA,0 ; set porta bit zero high=09 pointaf decf C1,f ;decrement the pass 1st time through call delay bcf STATUS,C ;clear carry bit rlf PORTA,same ;rotate left porta ,store result in porta btfsc PORTA,3 goto pascnt2 movf C1,f ;move pass counter to w w and back to effect z flag btfss STATUS,Z ;skip next line in top bit set goto pointaf pascnt2 movlw 0x09 ;load pass counter with 8=20 movwf C1 ;load c1 with 8 setbitbf clrf PORTA bsf PORTB,0 ;set portb bit zero high pointbf decf C1,F ;decrement c1 by 1 call delay bcf STATUS,C ;clear carry bit rlf PORTB,same ;rotate left portb, store result in portb =09 btfsc PORTB,7 goto pascnt3 movf C1,F btfss STATUS,Z ;skip next line if top bit set goto pointbf ;************************************************************************= ** ; port a,b bacwards ;************************************************************************= ** pascnt3 movlw 0x09 ;load passcounter with 9 movwf C1 ;becasue we have 8 bits setbitbr clrf PORTA=09 bsf PORTB,7 ;set bit 7 high pointbr decf C1,F clrf STATUS call delay bcf STATUS,C ;clear carry bit rrf PORTB,same ;rotate right 1 bit store in b btfsc PORTB,0 goto pascnt4 movf C1,F btfss STATUS,Z=09 goto pointbr pascnt4=09 movlw 0x05 movwf C1 setbitar clrf PORTA=09 bsf PORTA,3 ;set bit 3 high pointar decf C1,F call delay bcf STATUS,C ; clear carry bit rrf PORTA,same ;rotate right 1 bit store in b btfsc PORTA,0 goto pascnt1 movf C1,F btfss STATUS,Z goto pointar goto pascnt1=09 ;************************************************************************= *********************** delay movlw 0x7f movwf D1 movlw 0xfF movwf D2 delay_0 decfsz D1,f goto $-1 decfsz D2,f goto delay_0 retlw 0x00 ;************************************************************************= ********************** end=09 =09 =09 ------=_NextPart_000_0014_01C3D933.89139FB0--