128k program memory ERROR
Moderators: David Barker, Jerry Messina
128k program memory ERROR
Hi,
when I try to compiler program, larger than 64K, the compiler hangs up, saying nothing, just stop compilling, no HEX file generated.
I use 18F47J13, which has 128k of prog mem.
Please check? Why it could be?
when I try to compiler program, larger than 64K, the compiler hangs up, saying nothing, just stop compilling, no HEX file generated.
I use 18F47J13, which has 128k of prog mem.
Please check? Why it could be?
- David Barker
- Swordfish Developer
- Posts: 1214
- Joined: Tue Oct 03, 2006 7:01 pm
- Location: Saltburn by the Sea, UK
- Contact:
- David Barker
- Swordfish Developer
- Posts: 1214
- Joined: Tue Oct 03, 2006 7:01 pm
- Location: Saltburn by the Sea, UK
- Contact:
- David Barker
- Swordfish Developer
- Posts: 1214
- Joined: Tue Oct 03, 2006 7:01 pm
- Location: Saltburn by the Sea, UK
- Contact:
Thanks for sending me your program. I built it using version 2.2.1.6 of the compiler, which took about 30 seconds on a lowly 2.8 GHz Pentium with just 1GB of RAM. I am quite happy with this performance, given the size of your program. I noticed in your email you are using version 2.2.1.0 of the compiler. Notice:
http://www.sfcompiler.co.uk/wiki/pmwiki ... ionHistory
version 2.2.1.5 introduced much improved compile times on large projects. I would urge anyone that notices a compiler problem to ensure they are using the latest version of the compiler before reporting an issue.
http://www.sfcompiler.co.uk/wiki/pmwiki ... ionHistory
version 2.2.1.5 introduced much improved compile times on large projects. I would urge anyone that notices a compiler problem to ensure they are using the latest version of the compiler before reporting an issue.
Now I use 2.2.1.6 version.
Large program compiles ok.
It is now 98kb, BUT still problems:
There are external data base named:
"rife.bas" -> these are names of the deseases (STRING constant)
"rife_freq.bas" -> the corresponding frequency (LONGWORD constant)
"oledfont" -> Character set for displayng on OLED (BYTE Coonstant)
Now, look at this video:
https://vimeo.com/61333740
This includes are at the following order:
include "oledfont"
include "rife_freq.bas"
include "rife.bas"
As you can see after Pr. 269 the names on the last display line disappears, even after moment, the program execution hangs, this is because the names file "rife.bas" is at last order.
If I put the "fire_freq.bas" to be the last include, than the program shows all name correctly, but after some position the frequency list becomes unavailable.
If I put "oledfont.bas" to be the last include, than the display do not show any characters correctly.
In all the cases the compiles generate *.HEX file, with no complains.
Clearly there is a bug in compiler, I suspect it cannot compile correct more than 64k useful code.
If I use smaller database, and the compiled code is 50k, everything works fine.
PICMicro used -> PIC18F47J13
Please, someone help!
Large program compiles ok.
It is now 98kb, BUT still problems:
There are external data base named:
"rife.bas" -> these are names of the deseases (STRING constant)
"rife_freq.bas" -> the corresponding frequency (LONGWORD constant)
"oledfont" -> Character set for displayng on OLED (BYTE Coonstant)
Now, look at this video:
https://vimeo.com/61333740
This includes are at the following order:
include "oledfont"
include "rife_freq.bas"
include "rife.bas"
As you can see after Pr. 269 the names on the last display line disappears, even after moment, the program execution hangs, this is because the names file "rife.bas" is at last order.
If I put the "fire_freq.bas" to be the last include, than the program shows all name correctly, but after some position the frequency list becomes unavailable.
If I put "oledfont.bas" to be the last include, than the display do not show any characters correctly.
In all the cases the compiles generate *.HEX file, with no complains.
Clearly there is a bug in compiler, I suspect it cannot compile correct more than 64k useful code.
If I use smaller database, and the compiled code is 50k, everything works fine.
PICMicro used -> PIC18F47J13
Please, someone help!
- David Barker
- Swordfish Developer
- Posts: 1214
- Joined: Tue Oct 03, 2006 7:01 pm
- Location: Saltburn by the Sea, UK
- Contact:
- David Barker
- Swordfish Developer
- Posts: 1214
- Joined: Tue Oct 03, 2006 7:01 pm
- Location: Saltburn by the Sea, UK
- Contact:
-
- Swordfish Developer
- Posts: 1473
- Joined: Fri Jan 30, 2009 6:27 pm
- Location: US
- David Barker
- Swordfish Developer
- Posts: 1214
- Joined: Tue Oct 03, 2006 7:01 pm
- Location: Saltburn by the Sea, UK
- Contact:
The compiler places all constant data in lower ROM, before any program data. If it extends into the next 64K block, it can cause problems for the in-built routines to handle. However, it is very easy to work around this. Here is an example:
You are basically replacing a "name(index)" array access with a function call. You wont need to rewrite your main code block - just add a public function like the above to your constants file and make the constant itself private.
Code: Select all
Include "usart.bas"
Include "convert.bas"
const SIZE_ARRAY = 5
Const cname(SIZE_ARRAY) As String = (
"Oranges",
"Apples",
"Melon",
"Pear",
"Lots of grapes!"
)
// maximum string size of single array element - including
// the null terminator
Const STR_SIZE = sizeof(cname) / SIZE_ARRAY
// get a name by index, uses 24 bit address...
Function name(index As Word) As String(STR_SIZE)
Dim addr As LongWord
// get address + offset, then load 24 bit address...
addr = AddressOf(cname) // address of constant string array
addr = addr + (index * STR_SIZE) // add the offset
TBLPTRU = addr.Byte2
TBLPTRH = addr.Byte1
TBLPTRL = addr.Byte0
' now read the string...
FSR0 = AddressOf(result)
Repeat
Asm
TBLRD *+
End Asm
POSTINC0 = TABLAT
Until TABLAT = 0 // look for null terminator
TBLPTRU = 0 // reset upper 8 bits!!...
End Function
// main program...
SetBaudrate(br19200)
Usart.Write("name = ", name(4), 13,10)
- David Barker
- Swordfish Developer
- Posts: 1214
- Joined: Tue Oct 03, 2006 7:01 pm
- Location: Saltburn by the Sea, UK
- Contact:
Great, thanks for letting us know. Don't forget, Swordfish will lay down array constants before any code and in the order encountered. For example,
include "int_constants.bas"
include "string_constants.bas"
will generate int_constants before string constants. If you swap them around, the ints may end up beyond 64K and you will need to use the above code technique on the int constants as well.
include "int_constants.bas"
include "string_constants.bas"
will generate int_constants before string constants. If you swap them around, the ints may end up beyond 64K and you will need to use the above code technique on the int constants as well.