16f84a running interrupt PICBASIC code


Closed Thread
Results 1 to 19 of 19

Hybrid View

  1. #1
    Join Date
    Jul 2008
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Am preparing a soft copy of the schematic and also a writeup of what is what in the program?

    Meanwhile I found that the chip actually resets everytime while executing the interrupt routine.
    Goes to beginning of code and starts executing again.

    WDT is OFF and I am not sure why this happening.
    Could there be some other reason?

    But the code works alright in the MPLAB SIM!!

    Divaker

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Who cares if it works in the MPLAB SIM or any other SIM.
    If a plane test flies well in the simulator, but crashes every time they try to test fly it in real life, which method of testing are you going to believe?

    Open up your datasheets, or do a Google search whatever for STACK UNDERFLOW or STACK OVERFLOW.
    You explained your problem in your last post, and it almost completely verified what I told you 2 or 3 posts ago.
    Meanwhile I found that the chip actually resets everytime while executing the interrupt routine.
    Goes to beginning of code and starts executing again.
    WDT is OFF and I am not sure why this happening.
    Again, how can you RETURN from somewhere you didn't GOSUB to?
    Same thing applies with an INTERRUPT. You can't RETFIE (RESUME) without an interrupt. Break out the datasheets and look up RETFIE, then break out your PBP manual and look up RESUME. An INTERRUPT is basically nothing more than a hardware generated CALL (not a GOTO because a CALL remembers where it came from). If you GOTO into your interrupt routine and expect it to come back where it came from, it's probably going to 'come back' to $0000, the RESET vector, whatever you want to call it. But actually, it's not going to do any of that, because you're going to have a STACK UNDERFLOW. You can't pull less than what's not there.
    I'm guessing you probably haven't tried rewriting your code yet?
    If you would've, you might avoid this problem altogether...

  3. #3
    Join Date
    Jul 2008
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Dear Skimask and Joe,

    Thanks guys for your kind suggestions for correcting the prob.
    The whole prob was due to the relay that I had connected to the output.
    It was the a typical case of not remembering to add a simple flyback diode. The relay was responsible for the prob.
    As soon as I corrected it, everything worked like plum.
    Thanks once 'gain.

    Divaker

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Didn't say anything about connecting a RELAY (yes, your code says solenoid, but you don't mention that it's actually hooked up)...
    Could've saved 15 posts over a few days...

Similar Threads

  1. Code works on 16F84A but not on 16F88?
    By pharaohamps in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 6th November 2009, 18:29
  2. Help with Analog Interrupt
    By brid0030 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th February 2008, 18:14
  3. 16F876A CCP1 Capture/Interrupt Question
    By TDonBass in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 17th January 2008, 03:25
  4. PicBasic code problems with a 16F84A
    By Lauren Barta in forum mel PIC BASIC
    Replies: 3
    Last Post: - 30th May 2006, 22:50
  5. NEWBIE: Some basic questions using interrupts
    By JackPollack in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 8th March 2006, 02:59

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