18F4520 Overwriting Previous Address?


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Jun 2015
    Posts
    8

    Default 18F4520 Overwriting Previous Address?

    I was given a few picbasic files and have been trying to get them to ICD compile for the 18F4520, but I keep getting this error:

    [ASM ERROR] Overwriting previous address contents (3200) (0) : Error[118]

    The first line of the code that I'm trying to compile is this:

    DEFINE RESET_ORG 3200h 'set the BASIC compiler's start after the assembly code


    Suspicious.

    From reading through some other posts with this issue, I have heard that the RESET_ORG nomenclature may have changed, or the "asm" and "endasm" commands. I am not sure if this is the source of my problem, though.


    The last time this code was compiled, the people used PBP 2.60A, earlier version of MicroCode Studio, and MPLab 8.something. I am using PBPX 3.0.8.4, MicroCode Studio Plus 5.0.0.5, and I have MPLabX installed. The Microchip assembler is linked and is currently at C:\Program Files (x86)\Microchip\MPLABX\v3.00\MPASMX.

    I have two source files- one is mostly PBP with some inline assembly, and it references a second file that is just a bunch of assembly routines. I am using MicroCode Studio Plus with PBP 3, and have MPLabX installed.


    What can I do to resolve this error and get the ICD compile to work?

    Thanks in advance!

  2. #2
    Join Date
    Jun 2015
    Posts
    8


    Did you find this post helpful? Yes | No

    Default Re: 18F4520 Overwriting Previous Address?

    Does anyone at least have any idea of how to start debugging this? Is there a way that I can tell the compiler to not overwrite previous address contents?

    Do I have to change anything in the code that was compiled with PBP 2.60A when I try to compile it with PBPX 3.0.8.4?

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,580


    Did you find this post helpful? Yes | No

    Default Re: 18F4520 Overwriting Previous Address?

    Hi,
    The usual reason for getting that particular error is that you're trying to overwrite the CONFIG bits. The way those are handled changed for the better with the arrival of PBP3.
    Your problem SEEMS unrelated to that but IF you have anything in your code which tries to set the CONFIG bits (ie @CONFIG etc) then it's probably it anyway and I'd take a close look at that.

    As a start, just comment it out, open the manual and read about the #CONFIG/#ENDCOFIG directives.

    /Henrik.

  4. #4
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: 18F4520 Overwriting Previous Address?

    Didn't this used to happen on 2.xx if you hadn't commented out the config settings in the PBP folder when using MPASM ?? Not sure if the same follows with PBP3 ??

  5. #5
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: 18F4520 Overwriting Previous Address?

    The case could be that any modification to the code before 3200h,
    or compiling with a different compiler has increased the code size so that it extends past 3200h.
    You could try moving the code somewhere later in the file with the org statement.
    I don’t think you can just move it anywhere. It must be the start of a code page (or something like that).
    PBP also uses org statements to organise where lookup tables are going to be,
    and doesn’t make you aware of where it’s going to put them.

    As it is right now, you could try just commenting some code before 3200h,
    even if it breaks the program for now, and if it compiles you should see how close your code has come
    (in the compiled hex file) to the address 3200h.
    It does sound to me like trying to write two sets of program data in the same location.
    Last edited by Art; - 29th June 2015 at 07:28.

  6. #6
    Join Date
    Jun 2015
    Posts
    8


    Did you find this post helpful? Yes | No

    Default Re: 18F4520 Overwriting Previous Address?

    Fixed it! So far...

    To clarify, no CONFIG commands were used in the code. All the registers were configured with #define statements.
    I forgot to mention that the code uses a bunch of assembly macros, all collected in a separate PBP file. That appeared to be the source of the instructions that were being overwritten.

    I looked into the ASM file that was generated by the compiler and saw that it was about 24 kb. I changed the RESET_ORG value to be just a bit beyond that just to see what would happen (thinking that this would tell the compiler to start writing instructions after 24 kb of memory) and it worked! No more overwritten addresses!

    HOWEVER, I have not determined if the code still works as intended on the device. That'll be the topic of another thread.

Similar Threads

  1. Overwriting previous address contents... oh no - not again!
    By PerlNoerd in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 11th February 2014, 17:24
  2. PBP v3.0 vs previous versions
    By MikeBZH in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 4th October 2011, 22:30
  3. Replies: 8
    Last Post: - 3rd March 2011, 23:20
  4. Comparators on 18F4520
    By RacerX10 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 28th August 2009, 00:33
  5. 18F4520 44 pin
    By ferrousduke in forum General
    Replies: 6
    Last Post: - 14th March 2008, 14:51

Members who have read this thread : 1

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts