problem with TMR0 in 16F877a

Discussion in 'Embedded Systems and Microcontrollers' started by eslamzidan, Dec 10, 2009.

  1. eslamzidan

    Thread Starter New Member

    Dec 10, 2009
    2
    0
    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!
     
  2. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    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)

    Code ( (Unknown Language)):
    1.  ORG     0x004             ; interrupt vector location
    2.         movwf   w_temp            ; save off current W register contents
    3.         movf    STATUS,w          ; move status register into W register
    4.         movwf    status_temp       ; save off contents of STATUS register
    5.  
    6.  
    7. ; isr code can go here or be located as a call subroutine elsewhere
    8.  
    9.  
    10.         movf    status_temp,w     ; retrieve copy of STATUS register
    11.         movwf    STATUS            ; restore pre-isr STATUS register contents
    12.         swapf   w_temp,f
    13.         swapf   w_temp,w          ; restore pre-isr W register contents
    14.         retfie                    ; return from interrupt
     
  3. eslamzidan

    Thread Starter New Member

    Dec 10, 2009
    2
    0
    Thanks for your reply

    i will revise the code with the aid of these notifications and i will feedback with the results
     
Loading...