Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

(ASM) LED blink project; but Blinks only once

Status
Not open for further replies.

shawnmk

Member
Dear All,

I have attached my code for blinking the LED connected to the RA3 port. However, I have tried various delay codes with no avail. I have written my own code and yet it fails. It seems the problem is in the loop lines. Please see my project attached. Help...
 

Attachments

  • LEDflash.zip
    2.1 KB · Views: 178
You wrote:-

Code:
Main    ;BSF     PORTA,2        ; Turn on LED connected to RA2 
		BSF     PORTA,3
		;BCF		PORTA,2
		;BCF		PORTA,3
Loop		movlw	b'11111111'
		movwf	countw
		decfsz	countw, 1
		goto 	Loop
		
		goto Main

That is wrong because the LED is only turned on. Even if it turned off by removing the semicolon, the LED would only be on for a very short time.

The Loop is also incorrect because the register 'countw' reset to b'11111111' each time round so it never gets to zero.

It should be something like:-

Code:
Main 		BSF     PORTA,3			;turn on LED
		movlw	b'11111111'
		movwf	countw
Loop		decfsz	countw, 1		;loop only goes back to here
		goto 	Loop

		BCF		PORTA,3		;turn off LED
		movlw	b'11111111'
		movwf	countw
loop2		decfsz	countw, 1
		goto 	Loop2
		
		goto Main
 
Thank you very much. Could you please try getting the LED to blink using the program?

It comes on when I press the Vdd on the PICKIT2 Programmer Software but it just doesnt blink for me no matter what loop or count I use...thanks
 
Last edited:
Your loop is loading 255 and counting down from there. It is too short of a delay at the moment even with two loops. You'll have to lengthen the delay in order to get it to blink. Search for 'SPI code help' the program there has an example delay code for a 8 Mhz chip. Also search for 'Assembly delay (16F88)' It has a good explanaton of delay code and a site to calculate delays.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top