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

    Talking

    Quote Originally Posted by WishMaster^ View Post
    I feel so noobish >)
    Really? Well...how many 'noob's' can say they fixed a problem on their own.
    I do believe you've done graduated out of the noob class...
    Now go let all the smoke out of a PIC to celebrate!

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


    Did you find this post helpful? Yes | No

    Arrow

    Quote Originally Posted by skimask View Post
    Really? Well...how many 'noob's' can say they fixed a problem on their own.
    I do believe you've done graduated out of the noob class...
    Now go let all the smoke out of a PIC to celebrate!
    I can count myself as a real rookie now!!

    Now that my program is growing, I encountered a new problem.
    The program is now some sort of stopwatch with 1 control button on portb.4.
    The problem is, that when I press the button, the timer won't start and it goes straight to "The time is: 00,00"

    What do I miss here?


    anyone? ^^

    Cheers,

    William

    /EDIT While I studied the behaviour of the program, I saw something odd... When i press RB4, INTCON.0 is set, BUT the interrupt enable bit is cleared on the same time. That's why it doesn't interrupt.

    Now I have forced the enable bit to stay set, only when I run it then it gives me an adress missmatch error. So that isn't the solution...

    Anyone with a clue what might reset INTCON.3?
    Attached Files Attached Files
    Last edited by WishMaster^; - 19th April 2007 at 13:02. Reason: Added a founding......
    ------------
    Oh Noes...
    ------------

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


    Did you find this post helpful? Yes | No

    Default Odd...

    Okay, in debug mode all works fine now, but, when I compile and load the program without the debugger, then it goes bananas. What I suspect now, is that there is a signal in PortB what is resonating when I press the button. This will cause many interrupts, making the microcontroller think that I press the stop button right away.

    That will explain why it skips the interrupt routine without the debugger on...

    Before I order any parts to solve this, I want to know if I'm close or not. So is this a problem that might occure while making something like this?



    Cheers,

    William
    Attached Files Attached Files
    ------------
    Oh Noes...
    ------------

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by WishMaster^
    A colleague told me to make some own save location (pclhulp, whulp and sthulp). I'm not sure if this is okay...
    I don't think I'd be listening to that guy too much.

    If you are using a chip with more than 2K of program memory,PBP automatically inserts code to do the context saving. It uses the wsave, ssave and psave variables. Why? I don't know. But it does.

    In the process of saving the context, it also changes the W and STATUS registers. So if you try to save and restore it with different variables, you're only saving the changed values. Then the real values never get restored.

    This will send PBP to the Funny Farm. Or at least the person trying to figure it out.

    So, lose the saving portion of the interrupt handler, then change the restore section to what's shown in the manual.

    HTH,
    DT

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    I don't think I'd be listening to that guy too much.

    If you are using a chip with more than 2K of program memory,PBP automatically inserts code to do the context saving. It uses the wsave, ssave and psave variables. Why? I don't know. But it does.

    In the process of saving the context, it also changes the W and STATUS registers. So if you try to save and restore it with different variables, you're only saving the changed values. Then the real values never get restored.

    This will send PBP to the Funny Farm. Or at least the person trying to figure it out.

    So, lose the saving portion of the interrupt handler, then change the restore section to what's shown in the manual.

    HTH,

    Allright! I already had my doubts about that! I changed it back right away and it works just as great! Thanks!

    I fixed the problem with the "resonating signal". Turned out I used a wrong capacitor so the signal sticked in the forbidden area too long...
    Back to newbie class for me I guess, haha.

    Now comes the real challenge, 3 time measurements at the same time with 3 different start/stop buttons. All working on interrupts... Wish me luck!

    Cheers,

    William
    ------------
    Oh Noes...
    ------------

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


    Did you find this post helpful? Yes | No

    Default Working code

    For those who want to make a Stopwatch, here is my code for it. You will have to tune Timer0 for exact readouts since it is not perfect yet. By 30 seconds it will be 1,5 seconds off (28,5 sec)

    It counts from 100 uS

    Have fun building your stopwatch

    Thanks to all who helped me to make the code as it is now!


    Cheers,

    William

    P.S, I'll keep you all informed about the 3-stopwatch-at-the-same-time-based-on-interrupts-program
    Attached Files Attached Files
    ------------
    Oh Noes...
    ------------

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by WishMaster^ View Post
    For those who want to make a Stopwatch, here is my code for it. You will have to tune Timer0 for exact readouts since it is not perfect yet. By 30 seconds it will be 1,5 seconds off (28,5 sec)
    It counts from 100 uS
    Have fun building your stopwatch
    Thanks to all who helped me to make the code as it is now!
    Cheers,
    William
    P.S, I'll keep you all informed about the 3-stopwatch-at-the-same-time-based-on-interrupts-program
    I almost hate to point this out to you since you've already got all this work into your project/code...but...
    Do a search on 'Olympic Timer'...
    You'll find a timer that Melanie did awhile back, and it's very accurate...well, at least as accuracte as your oscillator is.

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, 02:35
  2. Sleep Mode
    By Pesticida in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th March 2008, 10:31
  3. Ping Darrel Taylor - Timer0 Instant Interrupt
    By JEC in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 9th January 2007, 11:20
  4. USART interrupt in PIC16F877A
    By amindzo in forum General
    Replies: 7
    Last Post: - 26th August 2006, 18:51
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01: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