problem with TMR0 in 16F877a

Thread Starter

eslamzidan

Joined Dec 10, 2009
2
i have a problem in using interrupt with TMR0 in pic16F877a

i tried to make a counter that counts from 0 to 9 one step every second but there is a problem when simulated it in proteus and a message "stack overflow" appeared

i am using easypic4 development kit and working on MPlab

the project files attached with the thread

can anybody help!
 

Attachments

Markd77

Joined Sep 7, 2009
2,806
Looking at cnt.asm you should use goto inter instead of call inter.
Also look at the interrupts section of the datasheet for your PIC. There is some code that you need to put at the beginning and end of the interrupt part: (you need to declare the files status_temp and w_temp)

Rich (BB code):
 ORG     0x004             ; interrupt vector location
        movwf   w_temp            ; save off current W register contents
        movf    STATUS,w          ; move status register into W register
        movwf    status_temp       ; save off contents of STATUS register


; isr code can go here or be located as a call subroutine elsewhere


        movf    status_temp,w     ; retrieve copy of STATUS register
        movwf    STATUS            ; restore pre-isr STATUS register contents
        swapf   w_temp,f
        swapf   w_temp,w          ; restore pre-isr W register contents
        retfie                    ; return from interrupt
 
Top