PIC16F877A - Timer0 won't interrupt


Closed Thread
Results 1 to 20 of 20

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Code:
    define loader_used 1  
    define osc 20        
    
    led var portc.1            ;LED is connected on PortC.1
    ledcnt var word
    
    wsave var   byte $20 system
    ssave var   byte bank0 system
    psave var   byte bank0 system
    
    Goto main
    
    define INTHAND tmroverflow
    
    asm
    tmroverflow movwf	wsave
                swapf	STATUS, W
                clrf	STATUS
                movwf	ssave              ;Interrupt
                movf	PCLATH, W          ;Routine
                movwf	psave              ;with Save function
                                           
                inc          _ledcnt            ;increment the counter
                
                movf	psave, W
                movwf	PCLATH
                swapf	ssave, W
                movwf	STATUS
                swapf	wsave, F
                swapf	wsave, W
                
                bcf     intcon,2           ;Clear Interrupt Flag
                
                retfie
    ENDASM
    
    main:
       INTCON = %10100000                  ;GIE enabled, T0IE enabled
       OPTION_REG = %00000101              ;Prescaler on TMR0 rate 1:32
       Output LED
       
    loop:
       led = ledcnt.7                     ;make the led follow bit 7 of ledcounter
       goto loop                           ;Wait here for interrupt
    A couple of changes. If you don't see the LED blink, turn up the prescaler and/or use a slower oscillator for test. At least you should see it work.

  2. #2
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default Typo or I missed that instruction

    Quote Originally Posted by skimask View Post
    [code]


    incf _ledcnt ;increment the counter

    Hi,

    Skimask I think it should be incf and is a simple typo.
    Regards

    Sougata

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sougata View Post
    Hi,

    Skimask I think it should be incf and is a simple typo.
    Yep, should be, and is......then again, it is Friday the 13th....maybe my keyboard is playing em no skcirt

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Interrupts and the MSC Debugger don't get along very well together.

    You must DISABLE debugging in any interrupt routines.
    Code:
    DISABLE DEBUG
    asm
    tmroverflow movwf	wsave
        ...
        ...
                retfie
    ENDASM
    ENABLE DEBUG
    For an 877, you should use $70 for the wsave address.

    OPTION_REG = %00000101 sets the prescaler to 1:64. (comment says 32)

    and, like skimask said ... set the LED's pin to output.
    DT

  5. #5
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Also a working example on MELABs website
    http://www.melabs.com/resources/samples/pbp/asmint.bas
    (maybe you got your start for yours there? I did not check if they are similar)
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  6. #6
    Join Date
    Apr 2007
    Location
    Delft, the Netherlands
    Posts
    10


    Did you find this post helpful? Yes | No

    Default

    Thanks all for your responds, will try them out on monday, it's weekend now. But thank you all very very much !!!

  7. #7
    Join Date
    Apr 2007
    Location
    Delft, the Netherlands
    Posts
    10


    Did you find this post helpful? Yes | No

    Default

    It's working perfectly!!! Thanks for the help!

    Cheers,

    William

Similar Threads

  1. Can't ID interrupt source with this IntHandler??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 3rd June 2009, 03:35
  2. Sleep Mode
    By Pesticida in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th March 2008, 11:31
  3. Ping Darrel Taylor - Timer0 Instant Interrupt
    By JEC in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 9th January 2007, 12:20
  4. USART interrupt in PIC16F877A
    By amindzo in forum General
    Replies: 7
    Last Post: - 26th August 2006, 19:51
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 02:07

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts