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.

small help in mplab and proteus

Status
Not open for further replies.

alalbeet

New Member
hi all

please help me in my problem that i began to write my first program in mplab which can change the state of the led on RB7 with the interrupt in RB0

my assembly code is as follows :-

PHP:
	LIST    P=PIC16F84
    #INCLUDE "P16F84.INC"
    __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
org 0x00
goto START
org 0x04
GOTO ISR
START
BSF STATUS,RP0
MOVLW 0X01
MOVWF TRISB
BCF OPTION_REG,INTEDG
BSF OPTION_REG,NOT_RBPU
BCF STATUS,RP0
CLRF PORTB
BSF PORTB,7
BSF INTCON,INTE
BSF INTCON,GIE
LOOP
GOTO LOOP
ISR
BCF INTCON,INTF
BTFSS PORTB,7
BSF PORTB,7
BCF PORTB,7
RETFIE
END

and the proteus files in the attachments

my problem is that the change in the led state can be done in the first time only and i want it to make that with every interrupt change

please help me as I'm a beginner
 

Attachments

  • 3.zip
    42.9 KB · Views: 111
Last edited:
Code:
ISR
BCF INTCON,INTF
BTFSS PORTB,7
BSF PORTB,7
[COLOR="Red"]BCF PORTB,7    ;Led allway off[/COLOR]
RETFIE
replace by this
Code:
ISR
BCF INTCON,INTF
 movlw	b'10000000' 
 xorwf PORTB,7	;toggle bit 7 Led On/Off
[COLOR="Blue"] ;if want interrupt by sw1 state
   movlw	b'01000000'
   bsf	 STATUS,RP0
   xorwf  OPTION_REG	;toggle INTEDG
   bcf	 STATUS,RP0
   ;if not skip above[/COLOR]
RETFIE
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top