Broken code


Closed Thread
Results 1 to 23 of 23

Thread: Broken code

Hybrid View

  1. #1
    Join Date
    Nov 2014
    Posts
    16


    Did you find this post helpful? Yes | No

    Default Re: Broken code

    Watchdog timer is off, I do use an Assembly interrupt routine to create a time base using TIMER2. AT 16 MHZ I can make a 1/100th second interrupt.
    I do not think I am overflowing the stack (or maybe I am?) as there is one GOSUB to one subroutine at a time in a Mainloop which contains nothing but a RETURN statement. If I move the subroutine further up in the code, it works fine. It seems like once it is further down enough, no subroutine will RETURN back.
    The PIC has 64K of code space, I should be nowhere near that. I wonder if I am crossing some 2K boundary or something like that or if the interrupt routine
    screws up a bank select register. I use MOVFF in the assembly interrupt routine to save W, STATUS, BSR, PCLATH upon entering, and restore upon exiting then RETFIE.

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: Broken code

    JOOQ I looked at 18F46K22 datasheet. You can read the stack pointer, STKPTR. Just before your call test the stack pointer. At least you know whether your about to overflow. And of course make sure you have STVREN on.

    George
    Last edited by towlerg; - 28th November 2014 at 19:41. Reason: old and stupid

  3. #3
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    704


    Did you find this post helpful? Yes | No

    Default Re: Broken code

    Mark, most people here, including myself, won't be able to help you with assembly language. Only a few here have gone to the dark side and know assembly .

    You said that the RETURN command in your subroutine doesn't seem to be working. It is very important to know the line where the program isn't working anymore. What I ussually do is to write a line of code to turn on an LED for 5 seconds. Then, I move that line toward the end of the program until the LED doesn't turn on anymore. Put this line before entering the subroutine and then inside the subroutine and let us know what you find out.
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

Similar Threads

  1. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 21:55
  2. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  3. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  4. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  5. Melanies RTC code has broken
    By keithdoxey in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 6th October 2006, 15:22

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