PDA

View Full Version : 18F4520 Overwriting Previous Address?



chrome
- 16th June 2015, 05:01
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!

chrome
- 25th June 2015, 02:41
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?

HenrikOlsson
- 25th June 2015, 06:09
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.

Scampy
- 26th June 2015, 01:15
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 ??

Art
- 29th June 2015, 06:26
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.

chrome
- 1st July 2015, 04:53
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.