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 16F84A LED Pattern Changing (RB0)

Status
Not open for further replies.

Gayan Soyza

Active Member
I just wrote a program to pic 16f84a that changing some led patterns when u
press the interrupt button(RB0).

circuit works like this

*RB0 switch
*LED's connected to other portB pins.

when the power is on it displaying pattern 1.
when u press switch due to the interrupt it change the pat1 to pat2.

My Ques is now its in the pat2 state.even if i press the switch it wont change.
because its looping inside the pat2.

This is what I want to do

when u press the interrupt button again must go to the other pattern.I hope to
change 5 patterns.

How can i do this ? How the code comes?

See the code in the attachment.
 

Attachments

  • INTERRUPT.txt
    752 bytes · Views: 198
You have an org at address h'00' then go on to put code there...not a great idea...
You are not saving the context of the processor either during interrupts which is just asking for trouble...
Start structuring your code using symbolic labels rather than addressing registers by their physical addresses. Things are made a lot easier for you if you use one of the include header files in Mplab.
 
I'd forget about interrupts for now and just poll the PortB interrupt bit.

Something like,
Code:
PAT1	MOVLW O2H
	MOVWF 06H
	CALL DELAY
	MOVLW 00H
	MOVWF 06H
	CALL DELAY
	btfss	INTCON,INTF;	check for port B interrupt
	GOTO	PAT1;		loop if no interrupt
	bcf	INTCON,INTF;	clear the int bit

PAT2
; pattern 2 stuff
	btfss	INTCON,INTF
	GOTO	PAT2
	bcf	INTCON,INTF
PAT3
; etc
	btfss	INTCON,INTF
	GOTO	PAT3
	bcf	INTCON,INTF

	goto PAT1

Once you work through the above and understand it, then you can try and get it working with interrupts.

Mike.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top