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.

hardware or software fault?

Status
Not open for further replies.

gastonanthony

New Member
hi guys, I made a simple PIC16f84A code (I have no other choice bec. this is the type of pic assigned for the homework) for differrent LED patterns, I simulated it in MPLAB very nicely, but wouldn't work when connected to the hardware, the PIC wouldn't respond to inputs
here's the code:
Code:
PROCESSOR 16f84a
#include "P16f84a.inc"
COUNT1	EQU	08h
COUNT2  EQU	09h
		clrf	PORTA
		bsf	STATUS,5
		movlw	00h
		movwf	TRISB
		movlw	0Fh
		movwf	TRISA
		bcf	STATUS,5
		goto	Start

; Make all LEDs Blink
ALLBLINK
		movlw	0FFh
		movwf	PORTB
		btfss	PORTA,3			;RA4 is the reset button
		goto	Start
		call	DELAY1
		movlw	00h
		movwf	PORTB
		call	DELAY1
		btfss	PORTA,3			;RA4 is the reset button
		goto	Start
		goto	ALLBLINK
RUNNING
		movlw	b'00000000'
		movwf	PORTB
		call	DELAY1
		btfss	PORTA,3			;RA4 is the reset button
		goto	Start
		movlw	b'00000001'
		movwf	PORTB
		call	DELAY1
		btfss	PORTA,3			;RA4 is the reset button
		goto	Start
		movlw	b'00000010'
		movwf	PORTB
		call	DELAY1
		btfss	PORTA,3			;RA4 is the reset button
		goto	Start
		movlw	b'00000100'
		movwf	PORTB
		call	DELAY1
		btfss	PORTA,3			;RA4 is the reset button
		goto	Start
		movlw	b'00001000'
		movwf	PORTB
		call	DELAY1
		btfss	PORTA,3			;RA4 is the reset button
		goto	Start
		movlw	b'00010000'
		movwf	PORTB
		call	DELAY1
		btfss	PORTA,3			;RA4 is the reset button
		goto	Start
		movlw	b'00100000'
		movwf	PORTB
		call	DELAY1
		btfss	PORTA,3			;RA4 is the reset button
		goto	Start
		movlw	b'01000000'
		movwf	PORTB
		call	DELAY1
		btfss	PORTA,3			;RA4 is the reset button
		goto	Start
		movlw	b'10000000'
		movwf	PORTB
		call	DELAY1
		btfss	PORTA,3			;RA4 is the reset button
		goto	Start
		goto	RUNNING
COUNTUP
		clrf	PORTB
		incf	PORTB
		btfss	PORTA,3			;RA4 is the reset button
		goto	Start
		call	DELAY1
		btfss	PORTA,3		;RA4 is the reset button
		goto	Start
		goto	COUNTUP
	
DELAY1
Loop1	btfss	PORTA,3			;RA4 is the reset button
		goto	Start
		decfsz	COUNT1,1
		goto	Loop1
		decfsz	COUNT2,1
		goto	Loop1
		return

		
Start	movlw	0FFh
		movwf	PORTA
		movlw	0FFh
		movwf   PORTB			;all lights on
		btfss	PORTA,0
		goto	ALLBLINK
		btfss	PORTA,1
		goto	RUNNING
		btfss	PORTA,2
		goto	COUNTUP
		goto	Start
		
		end

hope somebody could help me out :D
 
The general purpose file register range for the 16F84A begins at address 0Ch instead of 08h. I don't know the behavior if you use the EEDATA and EEADR registers as count registers. EEADR is only 6-bits.

My guess is that the code originated from a program for an even older 16C54 chip.
 
motion is right

COUNT1 EQU 08h
COUNT2 EQU 09h

must not assigned to 08h & 09h

& also learn C & picbasic langague for PICs

they are more easier

good luck :wink:
 
DTMF said:
motion is right

COUNT1 EQU 08h
COUNT2 EQU 09h

must not assigned to 08h & 09h

& also learn C & picbasic langague for PICs

they are more easier

good luck :wink:
Actually it is better to learn Assembly first and then move to high-level languages (as said in my sticky)...
 
Jay.slovak yes offcorse

but i am helping him to move quikly to a higher level

but you are right :wink:
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top