View previous topic :: View next topic |
Author |
Message |
ilker07
Joined: 03 Jun 2022 Posts: 32
|
ccs c not enough ram for all variables |
Posted: Tue Oct 25, 2022 2:03 pm |
|
|
Code: |
#include <18F67K22.h>
#DEVICE PASS_STRINGS=IN_RAM
#use delay(internal=8000000)
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES NOBROWNOUT //No brownout reset
#FUSES PROTECT
#include <array.c>
void main(void)
{
while(TRUE)
{
}
}
|
|
|
|
ilker07
Joined: 03 Jun 2022 Posts: 32
|
|
Posted: Tue Oct 25, 2022 2:05 pm |
|
|
array.c
Code: |
const unsigned int16 arr [] = {
0x7d15, 0x7d15, 0x7d15, 0x7d15, 0x7d15, 0x7d15, 0x7d15, 0x7d15, ....
} |
There are 57600 items.
When I click compile, ccs c compiler freezes. Why is it happening?
Last edited by ilker07 on Tue Oct 25, 2022 2:08 pm; edited 1 time in total |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Wed Oct 26, 2022 1:18 am |
|
|
57600 elements. 16bits each = 921600 bits of memory. your chip only has
1024000 bits of memory in total. So you would not have much space for any
other code if this was accepted!.
However a const array is not allowed to be larger than a single page in
program memory. So you might be able to get it to compile by splitting
the table.
Honestly if you need a data array this large, put it in en external EEPROM,
and keep your program memory for code. |
|
|
ilker07
Joined: 03 Jun 2022 Posts: 32
|
|
Posted: Wed Oct 26, 2022 1:23 am |
|
|
Ttelmah wrote: | 57600 elements. 16bits each = 921600 bits of memory. your chip only has
1024000 bits of memory in total. So you would not have much space for any
other code if this was accepted!.
However a const array is not allowed to be larger than a single page in
program memory. So you might be able to get it to compile by splitting
the table.
Honestly if you need a data array this large, put it in en external EEPROM,
and keep your program memory for code. |
I am gonna use this array for displaying image with ST7789. Is there any way to do that? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Wed Oct 26, 2022 4:40 am |
|
|
The key problem is that you won't have enough memory in the PIC to actually
do the code, if you are using this much of it's ROM for data.
You can write raw data into the ROM using #import, and access this with
the read_program_memory function, but it will just use too much of the
ROM for the chip to be able then to control the display chip.
An external memory avoids this problem, and if you use a fast SPI interfaced
chip, a read could be done in a couple of instruction cycles. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Wed Oct 26, 2022 5:43 am |
|
|
sigh, I'm getting old..
First thing I thought of was YIKES 57,600 x 6 numbers to type in...over 1/3 of a million key presses.....with my bum finger and 'swapping of ekys' (getting worse these days.. ) there's no way the array would be 100% accurate....probably cause no end of grief IF the program actually worked !!
I agree, use an external EEPROM and when you've created the array 'file', back it up on HD and flash drive SEVERAL times !! If direct access is too slow, you could use a 'buffer', say a page at a time ? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Sat Oct 29, 2022 3:14 am |
|
|
If he simply creates an array with a few elements, and then makes it
larger by putting a bigger number into the [], he will see how the memory
usage rises, and where the limit is.
[30000] will merrily compile and use 46% of the chips ROM. Take it above
just over 32700, and the compiler will no longer accept it, since it will not
fit into a ROM bank (65536 bytes). There is tiny bit of access code that
has to be put into the same bank as the array, which limits the maximum
to about 32750 elements.
Split it into two 28800 element arrays, and it will compile, but the chip
then has less than 12% space left. Under 4000 instructions. Not likely to
be enough to do anything with a chip as complex as a display controller.
Also this space is split between two banks, so the largest piece of code
can only be a couple of thousand instructions.
You need to rethink this. It is just not going to work. |
|
|
|