Need help - need to flash a LED on PortA

Dec 19, 2003 2 Replies

Hi, this is driving me insane. I am unable to figure out why my code (below) to blink a LED on PortA does not work. The test circuit is fine. Everything compiles and burns onto the 628A PIC chip. But it does not do jack.



Could someone please help me out here.



Thank you, zalzon


------ ;portsend.asm to show to flash a led on porta, ra0.



;************************************* setup



list p = 16F628A ;processor type org 0020h



STATUS equ h'3' CMCON equ h'1F' TRISA equ h'85' RP1 equ h'6' RP0 equ h'5' PORTA equ h'05' reg1 equ h'20'



;************************************* program



goto Start



Start MOVLW 0x07 ;disable the comparators MOVWF CMCON



bsf STATUS, RP0 ;switch to bank 1 bcf STATUS, RP1



movlw b'00000000' ;all IO pins = outputs movwf TRISA



bcf STATUS, RP0 ;switch back to bank 0 bcf STATUS, RP1



movlw b'00000000' ; all port pins = low movwf PORTA goto Test


Test movlw d'255' ;counter to delay for a few milliseconds movwf reg1 BSF PORTA,0 ;set porta, bit 0 on goto Decrement1 ;begin delay Back1 BCF PORTA,0 ;set porta, bit 0 off movlw d'255' movwf reg1 goto Decrement2 Back2 goto Test


Decrement1 nop nop nop decfsz reg1, 1 goto Decrement1 goto Back1



Decrement2 nop nop nop decfsz reg1, 1 goto Decrement2 goto Back2



Finished end


You need to set an org for the code memory. Try using CBLOCK rather than org for the file registers, if you want to write your program in absolute.

Best regards, Spehro Pefhany

"it's the network..." "The Journey is the reward" speff@interlog.com Info for manufacturers: http://www.trexon.com Embedded software/hardware/analog Info for designers: http://www.speff.com

Hi, pic code starts at org0 not 20. You can find some templates on the microchip site. Some chips have adconverters on porta, they come up as analoge from reset.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required