Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Help me with a simple program with interrupt for PIC16f84a

Status
Not open for further replies.

gladtor_455

Newbie level 5
Joined
May 16, 2009
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,357
hi every one
i am new to pic and i want to do a simple program with interrup for pic16f84a
it is jus when i get signsl on RB0 all porta change to on status
this is the programe but it dosent work
if any one can tell me what is the problem
Processor Type PIC16F877A .


LIST P=16F84A
;********************************************************************************************************$
; Include An Additional File In The Program .


#INCLUDE "P16F84A.INC"
;********************************************************************************************************$
; Configuration Register Bits .


__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
;********************************************************************************************************$
; Reset Vector .


org 0x00
GOTO Start


org 0x04

banksel PORTA
bsf PORTA,1


retfie


bsf INTCON,7
bsf INTCON,4


Start
Banksel TRISB
movlw b'11111111'
movwf TRISB
BANKSEL TRISA
clrf TRISA
BANKSEL PORTA
clrf PORTA





LOOP GOTO LOOP





END
 

Re: interrupt__PIC16f84a

Hi,

Once you have enabled all your sub Interrupts you then need to enable the Global Interrupt. GIE

Perhaps for your little test you might get away without using 'Contex Saving' in the interrupt vector, but you should always uses it, otherwise when it returns from the Interrupt the relevant system data may be overwritten / lost.

See the F84 datasheet for full details
 

Re: interrupt__PIC16f84a

Hi,

Once you have enabled all your sub Interrupts you then need to enable the Global Interrupt. GIE

Perhaps for your little test you might get away without using 'Contex Saving' in the interrupt vector, but you should always uses it, otherwise when it returns from the Interrupt the relevant system data may be overwritten / lost.

See the F84 datasheet for full details

can you correct my program
 

Re: interrupt__PIC16f84a

Hi,

You just need the right interrupt flags setting, this code works ok in a simulator when RB0 is taken high.
Its often clearer to use their names rather than a bit number.

Set your ports up before you set the interrupts.

As soon as you use any more code you will need to include the context saving.



Code:
    LIST P=16F84A
    ;************************************************* ************************************************** *****$
    ; Include An Additional File In The Program .


    #INCLUDE "P16F84A.INC"
    ;************************************************* ************************************************** *****$
    ; Configuration Register Bits .


    __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
    ;************************************************* ************************************************** *****$
    ; Reset Vector .


    org 0x00
    GOTO Start


    org 0x04

    banksel PORTA
    bsf PORTA,1


    retfie


  


Start
    Banksel TRISB
    movlw b'11111111'
    movwf TRISB
    BANKSEL TRISA
    clrf TRISA
    BANKSEL PORTA
    clrf PORTA

	 BSF OPTION_REG, INTEDG   ; interrupt on positive
     BCF INTCON, INTF    ; clear interrupt flag
     BSF INTCON, INTE    ; mask for external interrupts
     BSF INTCON, GIE     ; enable interrupts


LOOP GOTO LOOP


    END
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top