PIC16F887 erratic behavior with DT interrupts


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2012
    Posts
    3

    Default PIC16F887 erratic behavior with DT interrupts

    I've been working on a program that uses Darrel's interrupts (thank you!) that has worked fine until I added more code. It uses portB interrupt on change.
    I am using PBP3 and Microcode Studio plus and the latest MPLAB assembler.
    It appears that a subroutine which works fine on the first call then behaves erratically when called a second time from another place, basically returning to an entirely different place in the program and gets stuck in a loop consisting of a few lines of code.
    The behavior is different if I move the interrupt handlers around in the program. Still gets stuck, just in different places.
    I get 3 'crossing page boundary' warnings.
    Thank you in advance for your thoughts?

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154


    Did you find this post helpful? Yes | No

    Default Re: PIC16F887 erratic behavior with DT interrupts

    Have you tried moving the interrupt handlers to the top of your program?

    It would be easier for members to help you if you posted your code.

    Suggestion: make a backup, trim your code down and test for changes (remove 1 logic at a time, it's easier to track down weird stuff).

    In-circuit debugging is awesome if your PIC is supported.

    I send messages to Microcode Studio Serial Communicator on the PC via RS232 to help debug.

    Robert

  3. #3
    Join Date
    Oct 2012
    Posts
    3


    Did you find this post helpful? Yes | No

    Default Re: PIC16F887 erratic behavior with DT interrupts

    Hi Robert,
    Thanks for your reply. The interrupt handlers are near the beginning of the program,after the main loop, but before all the subs. I moved them to the very beginning with the similar results, although it does seem to make a difference in exactly where the program goes.
    Tonight I'll take up your suggestion to reduce the code and see I can get more insight that way. I had the ICD working at one point, but have not had much luck with that recently, but I may spend some time trying to fix that. I'll also see if I can get the serial communicator working, but the program functions are time sensitive and the ICD and serial activity slows things down too much.
    I've been monitoring the I2C bus and also added a debug LED to see where the code is going, which is how I know it's going places that it shouldn't.
    Gordon

  4. #4
    Join Date
    Oct 2012
    Posts
    3


    Did you find this post helpful? Yes | No

    Default Re: PIC16F887 erratic behavior with DT interrupts

    I can post the program, but it's pretty convoluted and may be hard to follow as it has 'grown' as I've added functionality. It interacts with a rotary encoder, a couple of switches, a DSP, a AM/FM tuner IC, and a stepper motor. I'm a hardware guy, who knows enough to comment and use sub's, but am not a software person by nature or training. So the structure may be sub optimal, at the least.
    I guess the question I have is..Is it possible that the compiler is creating this problem, or is it something about the interrupt assembly code, or should I continue to look for an error in my code?
    Anyway, if someone wants to look at it I'll post it here.

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: PIC16F887 erratic behavior with DT interrupts

    Is it possible that the compiler is creating this problem, or is it something about the interrupt assembly code, or should I continue to look for an error in my code?
    I will bet on the last option

    Post your code and let someone offer some help.
    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. Erratic Behavior on a 18F452
    By markcadcam in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 18th October 2010, 17:20
  2. Replies: 8
    Last Post: - 7th December 2006, 15:42
  3. erratic behavior when using MPASM vs. PM
    By cool_justin in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th June 2006, 01:08
  4. Erratic LCD behavior
    By Travin77 in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 1st April 2006, 19:48
  5. Erratic PIC12F675 behavior
    By russman613 in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 27th February 2006, 14:46

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