Crashing program


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    A couple of lines got left off. The basic flow is:
    ---------------------------------------------------------------------

    DEFINE INTHAND IntSerial

    (Setup main registers)

    wsave VAR BYTE bankA system
    ssave VAR BYTE bankA system
    fsave VAR WORD bankA system

    (Define other variables)


    GOTO START

    ************** ISR STARTS HERE *************
    asm
    IntSerial

    (Save W,STATUS,FSR0)

    endasm

    (BASIC PROGRAM to handle serial buffer, sets flag when carriage return received)


    asm
    (Restore W,STATUS,FSR0)
    endasm

    ************ ISR ENDS HERE ***************

    START:

    (BASIC PROGRAM to handle buffer, do other things)

    GOTO START

    ---------------------------------------------------------------

    The program runs, but every once in awhile, I get odd port bits toggling.
    Must I write my entire ISR in assembly, or can I keep it in BASIC as I am doing now?
    Charles Linquist

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Hi Charles,

    With assembler interrupts, you have two options.

    1. Write your entire interrupt handler in assembler.

    2. Save all PBP system variables on entry, and restore all PBP system
    variables on exit, from your interrupt handler.

    With assembler interrupts, you can interrupt any PBP command in mid-stroke.
    What this means is you exit from "any" command whether it's completed
    execution or not.

    Then when you enter your interrupt handler, and use BASIC commands, you
    are again using PBP system variables.

    If you over-write a single system variable that was being used at the time
    the interrupt occured, then once you return to the interrupted BASIC library
    routine, there's a good chance you have corrupted whatever system variables
    were being used by the interrupted BASIC library function.

    Your program goes haywire, and the rest is history.

    Darrel posted several excellent interrupt routines. Take a peek at this thread
    http://www.picbasic.co.uk/forum/showthread.php?t=3251

    The .lst file generated at compile time gives you a full list of all system vars
    you'll need to save/restore during an assembler interrupt.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

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


    Did you find this post helpful? Yes | No

    Default Please post your basic code

    Hi,

    What are you doing inside the basic routine ? If you are sure that you program is not taking much time for a single example then depending on the input baud rate / execution speed you can even handle the entire stuff in PBP. But if it needs to be fast then it is best to write in asm completely. Saving the PBP variables can be a little tricky if your code grows with future requirement. As you mentioned you are new to asm (so am I) give it a try and there are guys out here who can help. Keep the Faith
    Regards

    Sougata

  4. #4
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    Unfortunately, Darrel himself states that the routines don't work with 18F parts - which is all I ever use.
    Charles Linquist

Similar Threads

  1. Presetting Configuration Fuses (PIC Defines) into your Program
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 82
    Last Post: - 15th December 2013, 09:54
  2. pic program crashing
    By comwarrior in forum General
    Replies: 5
    Last Post: - 8th July 2009, 16:33
  3. Replies: 1
    Last Post: - 23rd May 2009, 09:22
  4. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  5. PIC16F684 Program question
    By Nicholas in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th December 2006, 14:30

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