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.

PIC code

Status
Not open for further replies.
Is there any problem with my PIC code?

1. you may better put the .asm file it would be better.

2. you may have to code the ORG and reset vector
3. Generally it is better to get the habit of leaving meaning full comments for every line, as it would help you in future as you write bigger and many more programs, and blind codes without comments cause confusion while debuggingg and adoppting patches in future programs tomorrow .

I am also a learner at this very stage so I wanted to share my thoughts
 
Your code looks fine except for the goto delay rather than call delay,
Code:
OUT_IN
		movlw	b'00000010'	
		movwf	PORTA
		[COLOR="Blue"]call[/COLOR]	delay
		clrf	PORTA
Loop1		movf	TMP,0
		sublw	00h
		btfsc	STATUS,2
		goto 	main
		goto	Loop1

OUT_OUT
		movlw	b'00000001'	
		movwf	PORTA
		[COLOR="blue"]call[/COLOR] 	delay
		clrf	PORTA
Loop2		movf	TMP,0
		sublw	01h
		btfsc	STATUS,2
		goto 	main
		goto	Loop2

Mike.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top