CALL instruction not working


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697

    Default CALL instruction not working

    I'm using a PIC24EP512GP806 and I'm writing some ASM30 code in the auxiliary flash section but I'm having a lot of trouble with the CALL instruction.

    Code:
    CALL sub_error
    BSET	led_lat, #led_lat_bit
    GOTO $
    
    
    ; Subroutine error
    sub_error:
    BSET	led_lat, #led_lat_bit
    BSET	led2_lat, #led2_lat_bit
    GOTO $
    When this code is run from auxiliary flash, as soon as it gets to the CALL instruction, the chip appears to reset (neither LED lights up).
    If I use BRA instead of CALL then it works as expected.
    If I run the above code from the normal area of flash then it works.
    I've confirmed it's at least getting to the CALL instruction.
    Watchdog is disabled.

    I believe there may be some issue with the CALL instruction handling large addresses. sub_error is located at 0x7FC10E but the Programmer's Reference Manual says it can handle 23-bit addresses.
    There are no compiler errors or warnings to suggest there's anything wrong with the code. I've also checked the errata sheet for this chip and can't see anything that could cause this issue.

    I've tried Googling but I can't find anything remotely useful and I'm at a loss for what to try next.

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: CALL instruction not working

    Where is your RETURN statement in the routine "sub_error"?
    Dave Purola,
    N8NTA
    EN82fn

  3. #3
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default Re: CALL instruction not working

    For the purpose of testing I just had it go into an endless loop in the subroutine.
    I've just added one in after "GOTO $" to rule that out but it's still resetting.

  4. #4
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: CALL instruction not working

    Are you sure, that you set up correct offset?
    Try to add hard coded address instead label.
    As I assume that flash adr 0 is not PC adr 0. Or I missed something?
    I'm also interested in your HW setup.

  5. #5
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default Re: CALL instruction not working

    I've spent a bit of time trying to get the debugger to work. I'm using an ICD3 but the dsPIC33E/PIC24E firmware seems to be quite buggy when using it as a debugger.

    It turns out that there was a bug in my custom compiler that was setting __SP_init and __SPLIM_init to 0. The PIC was correctly erroring because of a stack overflow.
    I've fixed the bug and it's all working now!


    @pedja089
    The main flash and auxiliary flash are both in the same flash space with the auxiliary section starting at 0x7FC000.
    The PC accesses both areas as if they are just 1 big area of flash so PC 0 would always be the start of the main flash.

    For the hardware, I'm using a custom PCB with the PIC24EP512GP806, an ENC28J60 with an RJ45 socket and a bunch of headers.
    It's currently plugged into a breadboard which gives me 2 LEDs that I've been using to "debug" the code

    I've uploaded a picture of the board if you're interested
    Name:  ETM2.jpg
Views: 644
Size:  335.7 KB
    Last edited by The Master; - 13th February 2021 at 17:12.

  6. #6
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: CALL instruction not working

    I assume that you had PIC18 connected with external flash.
    I totally missed your first sentence in first post. Sorry about that.

Similar Threads

  1. 12F510 CALL subroutine problem ...
    By LakisFM1 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 15th November 2011, 10:21
  2. how to establish data call ??
    By hjahshan in forum GSM
    Replies: 20
    Last Post: - 14th April 2011, 23:28
  3. PWM instruction not working as I expect
    By peu in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 20th January 2006, 20:39
  4. Replies: 3
    Last Post: - 15th December 2005, 08:31
  5. Missed call
    By Lotondo in forum GSM
    Replies: 1
    Last Post: - 29th September 2005, 16:39

Members who have read this thread : 3

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